web.xml文件報錯:cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.


<?xml version="1.0" encoding="UTF-8"?>  
<web-app  
        version="3.0"  
        xmlns="http://java.sun.com/xml/ns/javaee"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 

報錯的servlet節點

 1   <servlet>
 2     <servlet-name>Spring</servlet-name>
 3     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 4     <load-on-startup>1</load-on-startup>
 5     <async-supported>true</async-supported>
 6     <init-param>
 7       <param-name>contextConfigLocation</param-name>
 8       <param-value>classpath:config/spring-servlet.xml</param-value>
 9     </init-param>
10   </servlet>

報錯提示在第6行

錯誤提示內容:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-
 role-ref, "http://java.sun.com/xml/ns/javaee":multipart-config}' is expected.

解決方法:

把4,5行放到9,10行之間,代碼如下

 1   <servlet>
 2     <servlet-name>Spring</servlet-name>
 3     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 4     <init-param>
 5       <param-name>contextConfigLocation</param-name>
 6       <param-value>classpath:config/spring-servlet.xml</param-value>
 7     </init-param>
 8     <load-on-startup>1</load-on-startup>
 9     <async-supported>true</async-supported>
10   </servlet>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM