struts2的执行顺序:
1.表单提交给action(如loginActio n)
<a href="testAction.action?id=11">action跳转测试</a>
<form action="flagSaveActionFlag.action" method="post">
2.到strus.xml
< package name ="com.StrutsDemo.Action" extends ="struts-default" > <!-- 用户管理的Action --> < action name ="*Action" class ="com.StrutsDemo.Action.UserInfoAction" method ="{1}" > < result name ="success" > /ook.jsp </ result > < result name ="error" > /error.jsp </ result > < result name ="userview" > /userview.jsp </ result > < result name ="index" type ="redirect" > /flagTestActionFlag.action?id=${id} </ result > </ action > < action name ="*ActionFlag" class ="com.StrutsDemo.Action.FlagAction" method ="{1}" > < result name ="success" > /ook.jsp </ result > < result name ="error" > /error.jsp </ result > </ action > </ package >
3.testAction.action在struts2.xml中找到“*Action”,再找到类com.StrutsDemo.Action.UserInfoAction,然后再到类中找test()方法;
public class UserInfoAction { // 其他方法 public String test(){ // 方法内容 return "index" ; }
4.再到struts2.xml中找到“*Action”下的<result name="index" type="redirect">/flagTestActionFlag.action?id=${id}</result>
继续按3跳转到struts2.xml中的“*ActionFlag”,再找到类com.StrutsDemo.Action.FlagAction下的方法flagTest(),再同3
5.结构图