【问题标题】:element web-app must be declared必须声明元素 web-app
【发布时间】:2015-05-15 13:14:51
【问题描述】:

我将这个项目从 svn 存储库检出到 IDEA 中,web.xml xsd 看起来像这样:

<web-app id="data-fabric-web-tool" 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">

我看到的第一个错误是必须声明“Element web-app”。 此外,对于文件中的每个标签,我都会收到“无法解析符号”错误。

【问题讨论】:

    标签: jakarta-ee web.xml


    【解决方案1】:

    根据:

    所有 Java EE 7 和更新的部署描述符模式共享 命名空间http://xmlns.jcp.org/xml/ns/javaee

    试试这个描述符命名空间定义:

    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1" id="data-fabric-web-tool">
    </web-app>
    

    【讨论】:

    • 结束标签中的错字:webapp -> web-app
    • @Yasser 谢谢!修好了!
    • 标签中元素的顺序重要吗?我收到一个错误和警告,提示 URL xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd 无法在 Eclipse 2020-12 中为 web.xml 加载,但替换上面的内容似乎可以消除这些错误。不同之处在于我有 id 然后是版本,然后是所有 xmlns 的东西,而在上面你有它们在版本和 id 之前。
    猜你喜欢
    • 2018-05-01
    • 2016-07-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-15
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多