一文解决,idea 中web.xml配置文件中webapp标签报红字错误

问题描述

导入项目发现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*)”.

在这里插入图片描述

解决方案

  1. 第一种,将上面的注释删掉
     “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” 
   	 “http://java.sun.com/dtd/web-app_2_3.dtd”
  1. 第二种,严格按照
icon?, display- (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*)”

顺序写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>Archetype Created Web Application</display-name>

    <filter>
        <filter-name>SessionFilter</filter-name>
        <filter-class>filter.SessionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>SessionFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>StartServlet</servlet-name>
        <servlet-class>servlet.BsStartServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>BsUserAction</servlet-name>
        <servlet-class>action.BsUserAction</servlet-class>
    </servlet>

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


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


    <taglib>
        <taglib-uri>http://yujian95.github.io/jstl/tag</taglib-uri>
        <taglib-location>WEB-INF/tag.tld</taglib-location>
    </taglib>
</web-app>

问题解决,希望对您有所帮助。

原文地址

作者:康帝957
来源:CSDN
原文:https://blog.csdn.net/kangdi957/article/details/81504870
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 7
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值