struts2和过滤器中作用域有关问题

struts2和过滤器中作用域问题!
我有个过滤器,先经过一个过滤器后在执行struts2的一个action。现在action中的每个方法都要request.setAttribute("paging", paging ); 这样重复很麻烦,我想把这句话放到过滤器中即:
过滤器中:
  

     public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain chain) throws IOExceptionServletException {
 HttpServletRequest request=(HttpServletRequest) arg0;
                  //过滤器前一些操作
         chain.doFilter(arg0, arg1);
                 //等执行完成后  我去一个工具类获取事先准备好的分页类
                  Paging paging= SysThreadLocal.getPageClazz();
               //然后放到作用域。
        request.setAttribute("paging", paging );
   }
  

这样的话我的action的每个方法中就不用再  
Paging paging= SysThreadLocal.getPageClazz();
request.setAttribute("paging", paging );
但是为什么这样页面得不到这个作用域的值!
如果我把
Paging paging= SysThreadLocal.getPageClazz();
request.setAttribute("paging", paging );
放到action的每个方法中,页面就可以获取到!
这个是为什么啊!???
如果过滤中用session 作用域,当然页面是可以获取到的,目前是在request中页面获取不到值
过滤器action struts2 

------解决方案--------------------
   public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain chain) throws IOException, ServletException {
         HttpServletRequest request=(HttpServletRequest) arg0;

    //等执行完成后  我去一个工具类获取事先准备好的分页类
                  Paging paging= SysThreadLocal.getPageClazz();
               //然后放到作用域。
            request.setAttribute("paging", paging );
                  //过滤器前一些操作
             chain.doFilter(arg0, arg1);
             
       }

要不要试试反写?我总觉得你过滤完以后action就直接跳转页面了  你后面的代码就不执行了 也不知道对不对
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

   public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain chain) throws IOException, ServletException {
         HttpServletRequest request=(HttpServletRequest) arg0;

    //等执行完成后  我去一个工具类获取事先准备好的分页类
                  Paging paging= SysThreadLocal.getPageClazz();
               //然后放到作用域。
            request.setAttribute("paging", paging );
                  //过滤器前一些操作
             chain.doFilter(arg0, arg1);
             
       }

要不要试试反写?我总觉得你过滤完以后action就直接跳转页面了  你后面的代码就不执行了 也不知道对不对

  chain.doFilter(arg0, arg1);
这句话执行后才执行的action里面的方法,如果放到  chain.doFilter(arg0, arg1);
之前,也就是说还没有执行action,那么分页类也会是一个空,因为分页的数据是action 调service调dao最后算出来的!


但是   chain.doFilter(arg0, arg1); 已经是拦截执行完毕 进行下一页正常跳转 跳入了你的action,那么你的request不写在前面怎么用?要不就提出个baseaction  每次在action里调用吧。 理解不是太好