Error reporting site restore
The header of the web.xml file is declared as follows:
<?xml version="1.0" encoding="UTF-8"?> <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">
The servlet
elements reporting errors are as follows:
<servlet> <description>Enter Dispatcher</description> <servlet-name>xxxMVC</servlet-name> <servlet-class>com.xxx.web.servlet.RequestDispatcher</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <param-name>xxxName</param-name> <param-value>xxxValue</param-value> </init-param> </servlet>
Or maybe this
Error prompt in <init-param>
the line, given the specific contents are as follows:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":enabled, "http://xmlns.jcp.org/xml/ns/javaee":async-supported, "http://xmlns.jcp.org/xml/ns/javaee":run-as, "http://xmlns.jcp.org/xml/ns/javaee":security- role-ref, "http://xmlns.jcp.org/xml/ns/javaee":multipart-config}' is expected.
Or the following error
Invalid content was found starting with element '{"http://xmlns.jcp.org/xml/ns/javaee":servlet-class}'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":description, "http://xmlns.jcp.org/xml/ns/javaee":display-name, "http://xmlns.jcp.org/xml/ns/javaee":icon, "http://xmlns.jcp.org/xml/ns/javaee":servlet-name}' is expected.
The solution is as follows:
The init-param
element to move the entire load-on-startup
element before, after modification, as follows:
<servlet> <description>Enter Dispatcher</description> <servlet-name>xxxMVC</servlet-name> <servlet-class>com.xxx.web.servlet.RequestDispatcher</servlet-class> <init-param> <param-name>xxxName</param-name> <param-value>xxxValue</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
Or
Error cause analysis (only for the first error):
Because it is the servlet
element of error, so we try to find the corresponding xsd file, look at the error place in violation of which of the restrictions or constraints. According to the statement xml file header, we know that the corresponding xsd files are http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd
, but from the web-app_3_1.xsd
file, we define the corresponding constraint did not find. However, we found the following code snippet:
<xsd:include schemaLocation="web-common_3_1.xsd"/>
So, we try to continue to web-common_3_1.xsd
find the corresponding limit or constraint, we find the following two snippets:
<xsd:element name="servlet" type="javaee:servletType"/>
<xsd:complexType name="servletType"> ...... <xsd:sequence> ...... <xsd:element name="init-param" type="javaee:param-valueType" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="load-on-startup" type="javaee:load-on-startupType" minOccurs="0"> </xsd:element> ...... </xsd:sequence> ...... </xsd:complexType>
From the above two pieces of code, we know that, for the servlet
elements, by <xsd:sequence>
limiting the order of appearance of the child elements init-param
must appear load-on-startup
before. At this point, we finally understand that the reason for the error is that we set the wrong order of the child elements.
Similar Posts:
- [Solved] Spring Error: Artifact spring:war exploded: Error during artifact deployment. See server log for details
- [Solved] com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes
- [Solved] Warning: Servlet threw load() exception java.lang.ClassNotFoundException: org.glassfish.jersey.servlet…
- How to Solve Error: The content of element type “web-app” must match “(icon?display
- [Solved] Spring MVC cross server upload error: returned a response status of 405 method not allowed
- The requested resource [/servlet] in JavaWeb is not available [How to Solve]
- [Solved] IDEA: JSP Could Not Use session Build-in Object
- Struts 2.0 Error: The Struts dispatcher cannot be found (Error 500 Internal Server Error)
- Tomcat set x-frame-option
- [Solved] Java EE file upload Error: web.xml error