以下是web.xml文件中的配置,但我对其中的Servlet过滤器配置有些疑问,话说当拦截到一个请求时,这时是调用pipi.web.WebContextFilter去处理这个请求呢?还是调用pipi.web.DispatchServlet来处理这个请求
  <servlet>
<servlet-name>DispatchServlet</servlet-name>
<servlet-class>pipi.web.DispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DispatchServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> <filter>
<filter-name>WebContextFilter</filter-name>
<filter-class>pipi.web.WebContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WebContextFilter</filter-name>
<servlet-name>DispatchServlet</servlet-name>
</filter-mapping>

解决方案 »

  1.   

    <filter-class>pipi.web.WebContextFilter</filter-class>
      

  2.   

    另外你这个web.xml能启动么? filter标签里面有<servlet-name>DispatchServlet</servlet-name>的标签吗?
      

  3.   

    过滤器 放在 servlet 的下面可以不可以启动???
      

  4.   

     有。。它可以有两种标签。一种用url-pattern   一种用servlet-name
      

  5.   

    那请问下servlet-class>pipi.web.DispatchServlet</servlet-class> 这个几时会调用呢? 如果过滤器调用的是<filter-class>pipi.web.WebContextFilter</filter-class>  那我servlet定义的class有什么用
      

  6.   

    指定filter的匹配方式有两种方法:直接指定url-pattern和指定servlet,后者相当于把指定的servlet对应的url-pattern作为filter的匹配模式
    filter的路径匹配和servlet是一样的,都遵循servlet规范中《SRV.11.2 Specification of Mappings》一节的说明
      

  7.   

    具体没试过, 要试的话在初始化的方法上打印就可以吧?
    另外我个人觉得xxx-name标签只是引用而已, 具体调用还是在class标签里的类.