服务器中加载web.xml文件的相关内容:
<servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
tomcat启动时加载web.xml的同时会加载struts-config.xml,并且会根据struts-config.xml的配置初始化相关对象。在struts-config.xml中
<action path="/index" attribute="messageForm" name="messageForm" type="org.gbook.action.IndexAction" parameter="method"> <forward name="main" path="/main.jsp"/> </action>