<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> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
actionServlet can assign multiple config files, separate by comma:
<init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config1.xml,</param-value> </init-param>
In Struts1, Each Action is a Servlet, and each Servlet is singleton
Action scope: Default is session
- request: request.setAttribute("UserForm",userForm); //auto runs by Struts1
- session: request.getSession().setAttribute("UserForm",userForm); //auto runs by Struts1
<action-mappings> <!-- localhost:8080/webapp/login.do, action path is the requested url path --> <!-- form-bean connect to the action identified by name --> <action path="/login" name="UserForm" scope="request" type="com.gvace.struts1login.actions.LoginAction"> <!-- action choose which forward to go by forward name --> <forward name="ok" path="/WEB-INF/welcome.jsp"></forward> <forward name="err" path="/WEB-INF/err.jsp"></forward> </action> </action-mappings>
No comments:
Post a Comment