配filter结果却404,不解(tomcat)
在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>
然后写了一个简单的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>
...全文
相关推荐
tomcat排错经典案例之404.docx
### Tomcat 排错经典案例之 404 错误详解#### 一、问题背景及概述在搭建 `Struts2 + Spring + Hibernate` 框架的过程中,遇到了常见的 HTTP 404 错误
linux系统下部署项目访问报404错误的解决方法
**日志排查**: - 查看Tomcat的日志文件,如`catalina.out`,它可能会提供关于404错误的详细信息。错误信息可以帮助你定位问题所在。8.
tomcat文档
>com.example.MyFilter</filter-class></filter><filter-mapping> <filter-name>MyFilter</filter-name> <url-pattern
Tomcat总结文档
</filter-class> ...
Tomcat web.xml,server.xml中详细配置说明文档
**配置异常页面(3.2.5)**```xml<error-page> <error-code>404</error-code> <location>/error/404.html</location>


Web 开发
