IDEA似乎与Servlet API 3.0 xml架构无关,但是我的web-app部署好了吗?

Pha*_*tok 4 xsd intellij-idea servlet-3.0

web.xml中

我能够使用基于注释的url-mappings从IDEA部署我的Web应用程序,所以为什么IDEA仍然强调标签违反了模式定义?

(使用IDEA 12.1.4,Tomcat 7)

mab*_*aba 5

IDEA正在根据架构验证您的XML,并正确地说明了这一点Element metadata-complete is not allowed here.

如果您查看架构,web-app_3.0.xsd您将看到它导入web-commmon_3.0.xsd.并且此web-common模式已定义metadata-complete为其中的一部分web-common-attributes.

<xsd:attributeGroup name="web-common-attributes">
  <xsd:attribute name="version"
                 type="javaee:web-app-versionType"
                 use="required"/>
  <xsd:attribute name="id"
                 type="xsd:ID"/>
  <xsd:attribute name="metadata-complete"
                 type="xsd:boolean">
    ...
Run Code Online (Sandbox Code Playgroud)

总之,这意味着metadata-complete是一个属性,以web-app元素.

改为将xml改为:

<?xml version=1.0 encoding="UTF-8"?>
<web-app 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"
         version="3.0"
         metadata-complete="false">

    <display-name>Hello World</display-name>

</web-app>
Run Code Online (Sandbox Code Playgroud)