web.xml 中的 cvc-id.3 错误

新手上路,请多包涵

在 Eclipse 中为 SpringMVC Web 应用程序编辑 web.xml 文件时收到此错误消息:

cvc-id.3: 身份约束字段“web-app-servlet-name-uniqueness”匹配元素“web-app”,但该元素没有简单类型。

这是我的 web.xml 的一部分:

 <?xml version="1.0" encoding="UTF-8" ?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="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"
    id="WebApp_ID" version="2.5">

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

错误指向 <servlet-name>dispatcher</servlet-name> 声明。我应该怎么做才能解决它?先感谢您。

原文由 Arsenicum 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 460
1 个回答

无意中发现把Java改成大写,错误就消失了:

xmlns="http://java.sun.com/xml/ns/javaee"

应该:

xmlns="http://JAVA.sun.com/xml/ns/javaee"

原文由 user2931195 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题