过滤器mapping报错

过滤器mapping报错

在web.xml中filter-mapping报错:提示信息如下

Multiple annotations found at this line:

- Invalid element name:

- filter-mapping


One of the following is expected:

- async-supported

- init-param


Error indicated by:

{http://xmlns.jcp.org/xml/ns/javaee}

with code:

- cvc-complex-type.2.4.a: 

Invalid content was found starting 

with element 'filter-mapping'. One of 

'{"http://xmlns.jcp.org/xml/ns/

javaee":async-supported, "http://

xmlns.jcp.org/xml/ns/javaee":init-

param}' is expected.


正在回答

登陆购买课程后可参与讨论,去登陆

2回答

同学你好,同学的   </filter-mapping>标签写错了位置,同学写在了 <filter>标签中

http://img1.sycdn.imooc.com//climg/5edcc104094ee06404700267.jpg

应该是在 <filter>标签的外面,
修改后如下

http://img1.sycdn.imooc.com//climg/5edcc11009274bbb05090256.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~


好帮手慕阿园 2020-06-07 17:43:28

同学你好,建议同学把web.xml中的代码粘贴到问答区,方便老师定位问题

祝学习愉快

  • 提问者 慕UI1578266 #1
    ?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>first-filter</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>MyFirstFilter</filter-name> <filter-class>com.imooc.filter.MyFirstFilter</filter-class> <filter-mapping> <filter-name>MyFirstFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </filter> </web-app>
    2020-06-07 17:48:54
  • 提问者 慕UI1578266 #2
    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>first-filter</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>MyFirstFilter</filter-name> <filter-class>com.imooc.filter.MyFirstFilter</filter-class> <filter-mapping> <filter-name>MyFirstFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </filter> </web-app>
    2020-06-07 17:49:35
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师