【发布时间】:2022-08-24 00:31:54
【问题描述】:
我的 web.xml 文件显示错误,我不知道为什么。当我转到该文件时,它在第二行的单词“<web-app”上显示红色 x。当我将鼠标悬停在错误上时,它会在下面显示此消息。
在此行找到多个注释:
- cvc-complex-type.4:属性 \'version\' 必须出现在元素 \'web-app\' 上。
- 属性:
- 元素中需要版本:
- 网络应用代码:
这是我的 web.xml 文件的代码
<?xml version=\"1.0\" encoding=\"UTF-8\"?> <web-app xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" id=\"WebApp_ID\"> <display-name>springboot-server</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</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>在问题表中,web.xml 的第二行显示了两个不同的错误。第一种错误是 语言服务器 第二类错误是 XML 问题.
-
我认为您需要在开始标签中指定网络应用程序版本。
<web-app version=\"2.4\" xmlns....... -
@arooney88 您能否指定开始标签中的网络应用程序版本的外观?以下是基于您的建议的网络应用程序代码开头的外观。
<web-app version=\"2.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" id=\"WebApp_ID\">我确实添加了版本,保存后仍然显示错误。
标签: java spring-boot web.xml