Tomcat - web.xml的xml錯誤解決方法!!


錯誤信息:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'. One of 
 '{"http://xmlns.jcp.org/xml/ns/javaee":servlet-class, "http://xmlns.jcp.org/xml/ns/javaee":jsp-file, "http://
 xmlns.jcp.org/xml/ns/javaee":init-param, "http://xmlns.jcp.org/xml/ns/javaee":load-on-startup, "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.

解決方法:

在xml文件的“xmlns:xsi”里面加入:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://java.sun.com/xml/ns/j2ee:servlet-class http://java.sun.com/xml/ns/j2ee" 

最終xml文件頭部如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://java.sun.com/xml/ns/j2ee:servlet-class http://java.sun.com/xml/ns/j2ee" 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
	id="WebApp_ID" version="4.0">

參考:

https://blog.csdn.net/caoxiaohong1005/article/details/53401880


免責聲明!

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



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