eclipse wtp 没有自动生成 web.xml

本文介绍了在Eclipse中创建Dynamic Web Project时未自动生成web.xml文件的问题及解决方法。通过使用Java EE Tools中的Generate Deployment Descriptor Stub功能,可以手动创建缺失的web.xml文件。此外,还讨论了在Servlet 3.0规范下如何利用注解替代web.xml进行配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

因此,运行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?

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.

 

转载于:https://www.cnblogs.com/johnsonshu/p/5512329.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值