加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 由于servlet文件导致的xml错误无法找到元素的声明,Refer

发布时间:2020-12-15 05:01:01 所属栏目:Java 来源:网络整理
导读:我不知道为什么会发生这些错误有人可以解释我如何解决它们 – cvc-elt.1:找不到元素’web_1:web-app’的声明. 引用文件包含错误(jar:file:/ C:/ Program Files / eclipse / plugins / org.eclipse.jst.standard.schemas_1.2.0.v201101142102.jar!/dtds
我不知道为什么会发生这些错误有人可以解释我如何解决它们 –

> cvc-elt.1:找不到元素’web_1:web-app’的声明.
>引用文件包含错误(jar:file:/ C:/ Program Files / eclipse / plugins / org.eclipse.jst.standard.schemas_1.2.0.v201101142102.jar!/dtdsAndSchemas/web-app_2_5.xsd).有关更多信息,请右键单击“问题视图”中的消息,然后选择“显示详细信息…”

这是我面临的两个错误,因为我错误地添加了一个servlet,我打算将一个普通的类文件添加到我的项目中.
然后这两个错误开始显示甚至我删除servlet文件.
这是我的xml代码(实际上它是基本代码) – 因为我还没有使用过单个servlet文件,我只使用了jsp文件.

仍然是xml文件 –

<?xml version="1.0" encoding="UTF-8"?>
    <web_1: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_4.xsd"
        xmlns:web_1="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_3_0.xsd"
        id="WebApp_ID"
        version="3.0">
        <display-name>InitialD</display-name>
        <web_1:welcome-file-list>
            <web_1:welcome-file>index.html</web_1:welcome-file>
            <web_1:welcome-file>index.htm</web_1:welcome-file>
            <web_1:welcome-file>index.jsp</web_1:welcome-file>
            <web_1:welcome-file>default.html</web_1:welcome-file>
            <web_1:welcome-file>default.htm</web_1:welcome-file>
            <web_1:welcome-file>default.jsp</web_1:welcome-file>
        </web_1:welcome-file-list>
    </web_1:web-app>

解决方法

正如Mark和Saurabh所说,从web.xml文件中删除“web_1:”的每个实例都是可行的.同时,最好删除对模式“xmlns:web_1”的引用.一个基于Saurabh问题的可行片段如下:

<?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_4.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID"
    version="3.0">
    <display-name>InitialD</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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读