ActionServlet的初始化过程

 

一:介绍

在tomcat的启动过程中,tomcat会读取/WEB-INF/web.xml文件中的配置信息进行一些初始化的工作,而Struts的启动工作就从这里开始.
在web.xml文件中有如下的配置信息:

即表示tomcat启动的时候会初始化org.apache.struts.action.ActionServlet类.

 



二: Struts的ActionServlet的初始化

首先看一下init()的源码:

1、initInternal()

     -------Initialize our internal MessageResources bundle

2、initOther()

    -----Initialize other global characteristics of the controller  servlet

3、initServlet()

     -----Initialize the servlet mapping under which our controller servlet is  being accessed

关于digester类解析xml文件请参考:

                         http://blog.csdn.net/wl_ldy/archive/2010/10/07/5925710.aspx



4、initChain()

5、getServletContext().setAttribute(Globals.ACTION_SERVLET_KEY, this)

   将ActionServlet实例以Globals.ACTION_SERVLET_KEY为key存在ServletContext对象中

6、initModuleConfigFactory()

    如果web.xml里ActionServlet配置中给出了 configFactory初始化参数,将其值指定的类做为Struts的ModuleConfigFactory,该值应该是一个完全限定类 名,Struts默认ModuleConfigFactory的实现是 org.apache.struts.config.impl.DefaultModuleConfigFactory。

7、  

8、this.initModulePrefixes(this.getServletContext());

   将上面while循环内产生的所有前缀生成一个String数组,放到ServletContext里。

9、this.destroyConfigDigester();

    将ActionServlet类的configDigester字段重置为null。


Come from:http://gemini.javaeye.com/category/8491?show_full=true 

 

 

 


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值