-->org.apache.struts.action.ActionServlet 所以本质上ActionServlet是一个普通的servlet,负责处理.do为后缀的Http请求. servlet在执行doGet(),doPost(),之前先调用init(), 以下我们先分析一下init()方法 /** * Initialize this servlet. Most of the processing has been factored into * support methods so that you can override particular functionality at a * fairly granular level.
* servlet初始化操作,注重初始化顺序 * @exception ServletException if we cannot configure ourselves correctly */ public void init() throws ServletException { //注重初始化的顺序 //Initialize our internal MessageResources bundle initInternal(); //Initialize other global characteristics of the controller servlet //处理一些全局变量的设置如:debug,detail等 initOther(); //Initialize the servlet mapping under which our controller servlet //is being accessed. This will be used in the &Html:form> //tag to generate correct destination URLs for form submissions //主要是注册DTD文件以及解析web.xml关于ActionServlet的配置。如后缀名等. // Configure the processing rules that we need // digester.addCallMethod("web-app/servlet-mapping", // "addServletMapping", 2); // digester.addCallParam("web-app/servlet-mapping/servlet-name", 0); // digester.addCallParam("web-app/servlet-mapping/url-pattern", 1); //initServlet()的上面一段将把Struts默认的后缀名从web.xml中解析得到 //也就是web.xml中的如下配置: // //action //*.do //默认以.do结尾的请求都将由Struts来处理,你可以自己修改 // initServlet();