<filter-mapping>
    <filter-name>BackgroundLogin</filter-name>
    <url-pattern>/background/*</url-pattern>
</filter-mapping>
我配置的这个过滤器,怎么只过滤
http://localhost:8080/demo/background/*.action下面的地址都没有过滤呢。
http://localhost:8080/demo/background/manager/*.action
http://localhost:8080/demo/background/webconif/*.action

解决方案 »

  1.   

    引用 2 楼  的回复:]
    引用 1 楼 gaulhor 的回复:
    高手帮帮忙呀 怎么没人理我呀
    我也需要帮忙
    [/Quote]回复测试。
      

  2.   

    *号表示后面可以是任意的  *号前面的不能变
      <url-pattern>/background/*</url-pattern>
    这个地址拦截的是 background/*(后面任意)
      

  3.   

    pengzhiyun就是呀 *号表示后面可以是任意的 
    http://localhost:8080/demo/background/*.action
    http://localhost:8080/demo/background/manager/*.action
    http://localhost:8080/demo/background/webconif/*.action这三个都应该过滤呀
      

  4.   

    不要那么懒,多配置几个filter标签
    <filter-mapping>
      <filter-name>BackgroundLogin</filter-name>
      <url-pattern>/background/manager/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>BackgroundLogin</filter-name>
      <url-pattern>/background/webconif/*</url-pattern>
    </filter-mapping>
      

  5.   

    这位哥们好像不是你说的这样, 那按照你这么说  我/*的过滤器就只拦截根路径.? 显然不是这样洒.!
    LZ把 url-pattern中的.action去掉看看
      

  6.   

    LS的兄弟们,不知道不要乱说话误导别人行不.? 如果filter都是按你们说的那样,那么ok,struts2不用干活了.!  我们都知道struts2的核心过滤器是要拦截/*,  好,如果按照你们说的,那就是说只拦截根路径的,我怎么知道有哪些子路径.? 如果filter设计成一个路径只能匹配他的根路径,那么这个设计是很失败的.!
    *通配就代表任何字符串, 包括/   
      

  7.   

    <url-pattern>/background/*</url-pattern>是可以匹配 /background/webconif/*.action,  /background/manager/*.action 的如果,请求没有到达 BackgroundLogin 这个过滤器, 可以检查下是否是因为
    请求被过滤链中的其它过滤器先行拦截了