Tag Archives: Java EE

Java web about web.xml 3.1

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
		 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1"&>
</web-app&>

pom.xmlweb.xml is missing and is set to true

1 web.xml is missing and <failOnMissingWebXml&> is set to true

The reason is that there is a lack of information in the project web.xml , and & lt; failonmissingwebxml &> is set to true

Solution: A. if the project needs web.xml To copy one web.xml Just add it to the project.

You can also use eclipse to generate: there are two ways

1. Right click on the project — &> Java EE tools — &> generate deployment descriptor stub. Then the system will display it in Src/main/webapp/Web_ Add INF file to create web.xml Documents. Error resolution!

2. Right click Project – &> properties – &> project faces to remove the check of dynamic web module, click apply, and then check it again, click the further configuration availber that appears below, and then select the generated directory to generate web.xml

        

        

B. if the project does not require web.xml , you need to pom.xml There are two ways to configure & lt; failonmissingwebxml &> to false

      1.

<build&>
    <plugins&>
        <plugin&>
            <groupId&>org.apache.maven.plugins</groupId&>
            <artifactId&>maven-war-plugin</artifactId&>
            <version&>2.6</version&>
            <configuration&>
                <failOnMissingWebXml&>false</failOnMissingWebXml&>
            </configuration&>
        </plugin&>
    </plugins&>
</build&>

      2.

<properties&>
    <failOnMissingWebXml&>false</failOnMissingWebXml&>
</properties&>

[web basics] about web.xml < welcome file list > in

<welcome-file-list&>
    <welcome-file&>index.html</welcome-file&>
    <welcome-file&>index.jsp</welcome-file&>
</welcome-file-list&>

function : specify the home page of the web project (i.e. visit ) http://localhost : 8080/ displayed page)

working principle : Taking the code above as an example, two home pages are set. Then, the system will check whether the file exists in the web directory in order. (that is, first check whether there is a index.html If there is, the file will be displayed; otherwise, check whether it exists index.jsp 。)

supplement :

If the URL pattern of the servlet is /* , then http://localhost : 8080/ does not match welcome file list, but matches the servlet

If the URL pattern is /, the servlet will match welcome file list when it fails to find a suitable match.

Reference

[1] About web.xml CSDN blog