New maven project in eclipse, and changing the web.xml version of the problem after the web project

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Construction of the project maven
Here Insert Picture Description

Built with maven Here Insert Picture Description
add tomcat jar package (servlet.jar package), modified version of jdk.
Here Insert Picture Description
The default web project web.xml version 2.3, and we need to change our desired version (3.1).

在这里有两种方式更改web.xml的版本:
右键项目–>属性–>project facets:

在这里有我们选择的属性"Dynamic Web Module",右边的2.3也即是我们的web.xml的版本,此时也将我们需要的jdk版本进行更改为我们自己使用的版本。当我们更改为3.1时如下所示:
Here Insert Picture Description

会显示“Cannot change version of project facet Dynamic Web Module to XX"的信息,为什么呢?右边的小方框显示了我们web.xml的版本需要相映的最低版本的jre的支持才行,但是你会发现当我们更改了下面的java的版本从1.5到1.8之后,也同样会这样。在这个时候方法来了,先把" Dynamic Web Module"前面的勾去掉然后点击Apply,再选择java(jre)的版本,同时也勾上" Dynamic Web Module",这是下面会有,记得先把原来的WEB-INF下的web.xml删除
Here Insert Picture Description
点击Further configuration available…然后进行如下操作**,记得先把原来的WEB-INF下的web.xml删除,路径不要写错**:
Here Insert Picture Description
然后再去修改我们的web.xml文件,把index.jsp放在最上面即可(或者在创建一个index.html):

<?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" 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>mavenTest</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Probably like this, ha ha, the process of reform may still point out the problem, will be able to own more than a few times the whole the whole good (written their own)!
Summary of problems:
1. If you forget to delete the old before the new web.xml will create successful, go back and delete, the same can be modified repeatedly to get back in a few java version and dynamic web version, without deleting the project.
2. Use version 4.0 may appear to create xml file is not complete, there is no project name or label is not welcome.
The last big move, it is not deleted if the entire project to rebuild it!

Guess you like

Origin blog.csdn.net/weixin_40358672/article/details/93982894