<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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_5.xsd">
引用的文件包含错误 (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd)。有关更多信息,请右键单击问题视图中的消息并选择“显示详细信息...”
通过文件“web.xml”验证文件“web-app_2_5.xsd”时检测到以下错误。在大多数情况下,可以通过直接验证“web-app_2_5.xsd”来检测这些错误。但是,只有在 web.xml 的上下文中验证 web-app_2_5.xsd 时,才有可能出现错误。
详细来说,我看到了很多这样的:
s4s-elt-character:除 xs:appinfo 和 xs:documentation 之外的架构元素中不允许使用非空白字符。看到'var _U =“未定义”;'
如果将
j2ee
替换为 javaee
,就可以正常工作了。
编辑:
<web-app version="2.5"
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_2_5.xsd">
编辑:
了解与此错误相关的任何进一步信息。请点击链接。在这里您将找到 Java EE 部署描述符 (web.xml) 的架构。
更换
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
与
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee;http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
解决方案是你必须在 URL 之间添加分号
我相信您不会再次收到错误:)
我建议你在 2 段之间添加
;
:
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
和 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
像这样:
:xsi:schemaLocation="http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
在 xsi:schemaLocation 之间添加分号,如下所示
"http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
这也解决了我在
<servlet-name>
标签行中的错误。
“cvc-id.3:身份约束'web-common-servlet-name-uniqueness'的字段与元素'web-app'匹配,但该元素没有简单类型。”
就我而言,我已经更换了
xsi:schemaLocation =“http://java.sun.com/../..”
与
xsi:schemaLocation =“http://xmlns.jcp.org/../..”
干杯!
从表面上看,schemaLocation 似乎是错误的。解决该问题似乎会重定向到 HTML 页面而不是 XSD 架构。
我建议简单地删除这一行,除非您确实想在运行时进行 XSD 验证。请记住,相关部分将由您的 servlet 容器进行验证。
如下所示替换 schemaLocation 已解决了我的错误:
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/j2ee; http://xmlns.jcp.org/xml/ns/j2ee/web-app_2_4.xsd"
如果我的解决方案对任何人都有帮助。我的问题是类似的(尽管对于不同的 XSD,但有相同的错误),我已经发布了我对这个也类似问题的解决方案:https://stackoverflow.com/a/78053918/2467349.