解决web.xml报错The content of element type “web-app” must match(正解)

realnode.png vps-under-title.png 科学上网教程 | 机场推荐 | 云深不知处(机场)

IntelliJ IDEA编辑器显示web.xml红叉,内容如下

The content of element type “web-app” must match “(icon ,display-

name ,description ,distributable ,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-

mapping*,session-config ,mime-mapping*,welcome-file-list ,error-page*,taglib*,resource-env-

ref*,resource-ref*,security-constraint*,login-config ,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)”.

- No grammar constraints (DTD or XML schema) detected for the document.

出错原因是web.xml标签顺序有问题,比如下面的顺序就是正确的:

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Agreport</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ureport-console-context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>ureportServlet</servlet-name>
        <servlet-class>com.bstek.ureport.console.UReportServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ureportServlet</servlet-name>
        <url-pattern>/ureport/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

而下面的顺序就会提示红叉:

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Agreport</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ureport-console-context.xml</param-value>
    </context-param>



    <servlet>
        <servlet-name>ureportServlet</servlet-name>
        <servlet-class>com.bstek.ureport.console.UReportServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ureportServlet</servlet-name>
        <url-pattern>/ureport/*</url-pattern>
    </servlet-mapping>

    <!--调正顺序-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

赞(0)
未经允许禁止转载:优米格 » 解决web.xml报错The content of element type “web-app” must match(正解)

评论 抢沙发

合作&反馈&投稿

商务合作、问题反馈、投稿,欢迎联系

广告合作侵权联系

登录

找回密码

注册

Ads Blocker Image Powered by Code Help Pro

检测到广告已被屏蔽

尊敬的优米格用户,

您好,系统检测到您使用了广告屏蔽组件。本网站并不包含任何侵入性广告,如果本站能给您一点帮助,还请将本站加入拦截白名单,这是我们仅有的收入来源!

网站的持续运作和改进,需要您的慷概帮助,感谢您的支持。

此致,
优米格 团队