【问题标题】:atributes in web.xml are not working eclipse keplerweb.xml 中的属性不起作用 Eclipse 开普勒
【发布时间】:2014-08-25 18:39:51
【问题描述】:

我正在使用 Spring 3、Apache-maven-3.2.2、Apache-tomcat-7.0.54。

<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">

编译时出错

Multiple annotations found at this line:
    - cvc-elt.1: Cannot find the declaration of element 'web-app'.
    - schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd', because 1) 
     could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

【问题讨论】:

    标签: java xml eclipse spring maven


    【解决方案1】:

    web.xml 中的第一行应该是: &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;

    您还可以使用以下标签: &lt;web-app version="3.0" 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_3_0.xsd"&gt; 如果可能的话,而不是您正在尝试的那个。这里使用的版本是 3.0 而不是您正在尝试的 2.5。

    请注意,如果您使用的是与 Java EE 6 兼容的服务器,则应使用 3.0 版。

    【讨论】:

    • 你不应该像这样改变版本。 3.0 版只能用于符合 Java EE 6 的应用程序服务器。
    • 是的,这就是我说如果可能的话:)
    • 我想你应该解释一下两者之间的区别。
    • 但是你做到了。我很感激。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 2012-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多