【问题标题】:Element web-app must be declared error in intellij (java,springmvc,maven)元素 web-app 必须在 intellij (java,springmvc,maven) 中声明错误
【发布时间】:2016-07-01 21:49:43
【问题描述】:

这是我的 web.xml 文件,其中获取元素 web-app 必须声明为错误

<web-app id="WebApp_ID" 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">

    <display-name>SpringMVC 3.2 + Google Chart</display-name>

    <servlet>
        <servlet-name>frontController</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>WEB-INF/applnConfig.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>frontController</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

【问题讨论】:

    标签: java maven web.xml


    【解决方案1】:

    您正在使用 javaee 命名空间 (http://java.sun.com/xml/ns/javaee) 中的部署描述符架构 (web-app_2_5.xsd) 版本 2.5。但是你已经给了 J2ee 命名空间 (http://java.sun.com/xml/ns/j2ee)。

    尝试使用 Java EE 7 命名空间:

    <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">
    </web-app>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-01
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 2023-02-15
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      相关资源
      最近更新 更多