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中添加:
<controller processorClass="org.apache.struts.action.RequestProcessor" />
指定RequestProcessor处理。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值