获取404当页面存在时

时间:2016-11-01 20:36:38

标签: tomcat servlets http-status-code-404

我使用Java Servlets,JSP和Filters来返回网页,并在输入以下网址时不断收到404错误:

  

www.mysite.com/download/
  www.mysite.com/store /

将传入的请求记录到过滤器时,我从未使用以下代码看到这些请求中的任何一个:

HttpServletRequest req = (HttpServletRequest) request;
System.out.println(req.getRequestURI());

但是,我看到所有其他传入请求。我错过了什么?

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
    <filter-name>MainController</filter-name>
    <filter-class>XXX.controller.MainController</filter-class>
</filter>
<filter>
        <filter-name>XSSFilter</filter-name>
        <filter-class>XXX.security.XSSFilter</filter-class>
    </filter>   
    <filter-mapping>
        <filter-name>XSSFilter</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>MainController</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>XXXControllerServlet</servlet-name>
    <servlet-class>XXX.controller.XXXControllerServlet</servlet-class>
</servlet>
<error-page>
        <error-code>403</error-code>
        <location>/error/Comp.jsp</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/XXXControllerServlet/*</location>
    </error-page>
    <error-page>
        <exception-type>404</exception-type>
        <location>/XXXControllerServlet/*</location>
    </error-page>

0 个答案:

没有答案
相关问题