Typical Struts2 workflow (remember that Struts2 is extremely customizable, its parts are well decoupled)
struts.xml => defines 'mappings':
- which
actionruns for each URL - one or more
results: which resource (usually a JSP) generates a view for each result returned by the action
, , , a struts.xml
<action name="add" class="example.SumAction">
<result name="error">/Error.jsp</result>
<result name="success">/SumResult.jsp</result>
</action>
Java:
public class SumAction {
private int x;
private int x;
private int z;
public String execute() {
z = x + y;
return "success";
}
}
http://mysite.com/mywebapp/add.action?x=10&y=20 Struts2 SumAction, x y execute. "" , "", "/SumResult.jsp", struts2, , .
Result: <b><s:property value="z" /></b>
, execute() .
, , +, , , , ( ). .