配filter结果却404,不解(tomcat)

uniqs uniqs 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在tomcat下,webapps下面,新建了一个web应用a
然后写了一个简单的filter,直接接过response
print一行文本.然后写web.xml.之后试图访问.
http://localhost/a/filter/xxx
结果404.
我不解,在webapps/a下面放了一个1.html.
http://localhost/a/1.html
404 again.
我修改了web.xml成
<web-app />
然后访问
http://localhost/a/1.html
OK.
请问这是怎么回事啊,和Tomcat的设置有关吧.
Tomcat:5.5.15

filter用的web.xml见下面.


<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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_4.xsd"
version="2.4">
<filter>
<filter-name>Hello</filter-name>
<filter-class>MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Hello</filtername>
<url-pattern>/filter/*</url-pattern>
</filter-mapping>
</web-app>
...全文
评论 3
收藏 已收藏
分享
返回顶部
uniqs
Web 开发 81,108 成员 341,721 内容