struts2 FilterDispatcher

1:在FilterDispatcher 类中有属性
  private static boolean serveStatic;
 private static ActionMapper actionMapper;
这两个属性通过容器Container进行注入的
struts-default.xml中有<bean class="org.apache.struts2.dispatcher.FilterDispatcher" static="true" />这样一句
就是注入static 属性.
然后在doFilter方法中去找访问的url有没有相应的ActionMapping(存放Action的)
如果没有的话再去找静态资源,在init方法中有        
String packages = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
也可以自己在web.xml中配置packages属性
然后就可以在浏览器中  访问处于org.apache.struts2.static,template,org.apache.struts2.interceptor.debugging
,web.xml中配置packages属性下访问资源,但是uri要以struts开始
比如我要访问org.apache.struts2.static下的optiontransferselect.js(jar文件解压就能看见)
/struts/optiontransferselect.js就能下载这个js
 
 
2:
finally {
            try {
                ActionContextCleanUp.cleanUp(req);
            } finally {
                UtilTimerStack.pop(timerKey);
            }
        }
 
ActionContextCleanUp的doFilter方法
finally {
                int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue();
                counterVal -= 1;
                request.setAttribute(COUNTER, new Integer(counterVal));
                cleanUp(request);
        }
ActionContextCleanUp的cleanUp方法清理资源
ActionContext.setContext(null);
Dispatcher.setInstance(null);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值