Eclipse 动态 Web 项目中的 web.xml 在哪里
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11658104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where is web.xml in Eclipse Dynamic Web Project
提问by Bohn
In Eclipse I clicked File->New->Dynamic Web Project and I am following a tutorial for Jersey that now wants me to go and change something in web.xml file...but I can't even find this file. What is it I am doing wrong?
在 Eclipse 中,我点击了 File->New->Dynamic Web Project,我正在学习 Jersey 的教程,它现在想让我去更改 web.xml 文件中的某些内容......但我什至找不到这个文件。我做错了什么?
回答by Vitor Braga
When you create a Dynamic Web Project you have the option to automatically create the web.xml file. If you don't mark that, the eclipse doesn't create it...
创建动态 Web 项目时,您可以选择自动创建 web.xml 文件。如果您不标记它,则日食不会创建它...
So, you have to add a new web.xml file in the WEB-INF folder.
因此,您必须在 WEB-INF 文件夹中添加一个新的 web.xml 文件。
To add a web.xml click on Next
-> Next
instead of Finish
. You will find it on the final screen of the wizard.
要添加 web.xml 单击Next
->Next
而不是Finish
。您将在向导的最后一个屏幕上找到它。
回答by Marco Paulo Ollivier
you can do it by Dynamic Web Project –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub.
您可以通过Dynamic Web Project –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub 来完成。
回答by Gurusinghe
回答by Fillipe Silva
When you open Eclipse you should click File→ New→ Dynamic Web Project, and make sure you checked Generate web.xml
, as described above.
当您打开 Eclipse 时,您应该单击File→ New→ Dynamic Web Project,并确保您选中了Generateweb.xml
,如上所述。
If you have already created the project, you should go to the WebContent/WEB-INF
folder, open web.xml
, and put the following lines:
如果您已经创建了项目,您应该转到WebContent/WEB-INF
文件夹,打开web.xml
,然后输入以下几行:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Application Name </display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
回答by deen
Might be your project is not JEE nature, to do this Right Click -> Properties -> Project Facets and click Convert to facet and check dynamic web module and ok. Now you will be able to see Java EE Tools.
可能是您的项目不是 JEE 性质,为此右键单击 -> 属性 -> 项目构面并单击转换为构面并检查动态 Web 模块,然后确定。现在您将能够看到 Java EE 工具。
回答by Nandu Software Engineer
Follow below steps to generate web.xml in Eclipse with existing Dynamic Web Project
按照以下步骤在 Eclipse 中使用现有的动态 Web 项目生成 web.xml
- Right Click on Created Dynamic Web Project
- Mouse Over Java EE Tools
- Click on Generate Deployment Descriptor Stub
- Now you are able to see web.xml file on WEB-INF folder
- 右键单击创建的动态 Web 项目
- 鼠标悬停在 Java EE 工具上
- 单击生成部署描述符存根
- 现在您可以在 WEB-INF 文件夹中看到 web.xml 文件
回答by Arne
The web.xml file should be listed right below the last line in your screenshot and resides in WebContent/WEB-INF
. If it is missing you might have missed to check the "Generate web.xml deployment descriptor" option on the third page of the Dynamic web project wizard.
web.xml 文件应列在屏幕截图最后一行的正下方,并位于WebContent/WEB-INF
. 如果缺少它,您可能错过了检查动态 Web 项目向导第三页上的“生成 web.xml 部署描述符”选项。
回答by user1442999
If you missed to check the "generate web.xml" option when creating a new project, no worries If it is a Dynamic Web Project in your project right click on "Deployment Descriptor:...." and Click on "Generate Deployment Descriptor Stub" this will create a minimal /webapp/WEB-INF/web.xml.
如果您在创建新项目时错过了“generate web.xml”选项,不用担心如果您的项目中是动态 Web 项目,请右键单击“Deployment Descriptor:....”并单击“Generate Deployment Descriptor” Stub”这将创建一个最小的/webapp/WEB-INF/web.xml。
回答by Mikhail Ionkin
For gradle / maven project you can use src/main/webapp/WEB-INF folder by default:
对于 gradle / maven 项目,您可以默认使用 src/main/webapp/WEB-INF 文件夹:
- main
- - java
- - resources
- - webapp
- - - META-INF
- - - - context.xml
- - - WEB-INF
- - - - web.xml
回答by Rahul
I think you are creating a project in the wrong way,I am going to post here in step by step
我认为您以错误的方式创建了一个项目,我将在这里一步一步地发布
Step 1: File>>New>>Project>>Web>>Dynamic Web Project
第一步:文件>>新建>>项目>>Web>>动态Web项目
Step 2: Enter Project Name>>Next>>Next>>
第二步:输入项目名称>>下一步>>下一步>>
Step 3: Check the checkbox for Generate web.xml deployment descriptor
第 3 步:选中 Generate web.xml 部署描述符复选框
Step 4: Finish
第 4 步:完成
Please follow this way you will get you web.xml file under WEB-INF folder
请按照这种方式,您将在 WEB-INF 文件夹下获得 web.xml 文件