这个web.xml错误是什么意思?

jac*_*ekn 19 schema web.xml

<?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">
Run Code Online (Sandbox Code Playgroud)

引用文件包含错误(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 ="undefined";'

Saz*_*man 52

如果更换j2eejavaee,它会正常工作.

编辑:

<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">
Run Code Online (Sandbox Code Playgroud)

编辑:

要了解与此错误相关的任何内容.请关注链接.在这里,您将找到Java EE部署描述符(web.xml)的模式.

  • wtf ..这很烦人! (3认同)
  • @jhohlfeld发布的模式列表目前在这里:http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html模式java <= 1.4使用j2ee和模式> = 1.5使用javaee (3认同)
  • 我有这个声明,但错误仍然存​​在 (3认同)

小智 33

更换

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
Run Code Online (Sandbox Code Playgroud)

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee;http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
Run Code Online (Sandbox Code Playgroud)

解决方案是您必须在URL之间放置分号

我相信你不会再次得到错误:)

  • 这样做的理由是什么?错误确实消失了,但我不知道会有什么副作用 (4认同)

小智 12

我建议你;在 2 段之间添加: xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://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">
Run Code Online (Sandbox Code Playgroud)


Mai*_*hil 9

在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’匹配,但该元素没有简单类型。”