首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts1.3 & struts 1.2 RequestProcessor差异

2012-11-20 
struts1.3& struts 1.2RequestProcessor区别struts1.2.9 ActionServlet:请

struts1.3 & struts 1.2 RequestProcessor区别
struts1.2.9 ==============================

ActionServlet:

请求dopost或doget调用: protected void process(HttpServletRequest request, HttpServletResponse response)        throws IOException, ServletException {        ModuleUtils.getInstance().selectModule(request, getServletContext());        ModuleConfig config = getModuleConfig(request);        RequestProcessor processor = getProcessorForModule(config);        if (processor == null) {           processor = getRequestProcessor(config);        }//在1.2.9中使用RequestProcessor 实例        processor.process(request, response);    }  //第一次请求到来时调用 protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config)        throws ServletException {    RequestProcessor processor = this.getProcessorForModule(config);    if (processor == null) {            try {                processor =                    (RequestProcessor) RequestUtils.applicationInstance(                        config.getControllerConfig().getProcessorClass()); 。。。。} 

=====================================================
ActionServlet.init()
的 moduleConfig.freeze()方法
由子类ModuleConfigImpl.class实现
  getControllerConfig().freeze(); public ControllerConfig getControllerConfig() {        if (this.controllerConfig == null) {            this.controllerConfig = new ControllerConfig();        }        return (this.controllerConfig);    }

在ControllerConfig中有:
protected String processorClass =
        "org.apache.struts.action.RequestProcessor";

所以在上面
ActionServlet的getRequestProcessor方法中返回的是org.apache.struts.action.RequestProcessor并创建实例

======================================================
而1.3.10中
ControllerConfig改为:
protected String processorClass =
        "org.apache.struts.chain.ComposableRequestProcessor";
所以实际使用ComposableRequestProcessor类处理struts流程
=================================================

可以在struts-config.xml中添加:
<controllerprocessor/>
指定RequestProcessor处理。

热点排行