分享

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

 shineboy1 2015-08-05

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 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 –> RightClick –> Java EE Tools –> Generate Deployment Descriptor Stub.

Java EE Tools and Generate Deployment Descriptor Stubs

You should see web.xml file immediately after that.

Web.xml file for Dynamic Web Project

Now it’s time to deploy project to Tomcat Web Server. Right click on Server and click Add and Remove.

Tomcat Server - Add Remove Project

Then add your recently converted Dynamic Web project to Configured section at right and you should be all set.

Select Project and Start Server

Have anything to add to this article? Please chime in and join the conversion.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多