eclipse wtp 没有自动生成 web.xml

因此,运行servlet 时出错了。

网上查了一下,好像说确实不会自动生成,但是运行应该没有问题的。

幸亏找到了手动生成web.xml的方法,也就不纠结了。

http://crunchify.com/eclipse-missing-web-xml-file-how-can-i-create-web-xml-in-eclipse/

Eclipse: Missing web.xml file? How can I create web.xml in Eclipse?

SHORT LINK:

Last Updated on March 3rd, 2016 by App Shah 12 Comments

Have you created Dynamic Web Project and created servlet and still are you missing web.xml file under\WebContent\WEB-INF\..?

Eclipse allows you to NOT create a web.xml file when you create Dynamic Web Project for Java EE 6, since the Java EE 6 spec (in general) and Servlet 3.0 spec (in particular) attempt to de-emphasize deployment descriptors.

You can use annotation to provide all the data that had been included in the web.xml file. You should read through the Servlet 3.0 spec from the jcp.org site to get a bit more explanatory text.

To change the url-mapping for a Servlet 3.0 servlet, the first place to look is in the source code for the servlet. Look for (and change) the value of the urlPatterns element.

If you are trying to create a web app based on Servlet 3.0, try to avoid creating a web.xml file.

But still if you need web.xml then you can do it by

  • Dynamic Web Project
  • Right Click
  • Java EE Tools
  • Generate Deployment Descriptor Stub

You should see web.xml file immediately after that.

上一篇:Android 日夜间切换Demo


下一篇:Linux下软件常见安装方式