The Result in Action has a type attribute, which has four common usage methods.
1.
/DemoJsp1.jsp
The address bar does not change when the server jumps.
Method for passing values:
In the address bar, enter http: // localhost: 8080/strutsdemo/hoho/s1? T = 1
JSP page write:
Write in struts. xml:
/DemoJsp1.jsp
You can receive the parameters. Because the server jumps, they share the content in valueStack. 2.
/DemoJsp2.jsp
Client jump, the address bar changes.
Method for passing values:
In the address bar, enter http: // localhost: 8080/strutsdemo/hoho/s2? T = 1
Write in struts. xml:
/DemoJsp2.jsp?r=${t}
Because it is a client jump, ValueStack does not exist, so the t content is saved to the parameters of the Stack Context, and the value can be called through # parameters. r.
The values of the following two methods are the same as those of the preceding method.
3.
S1
/Hoho
You can jump to action. The server jumps to the action and the address bar does not change.
4.
s2
/hoho
You can jump to action, client jump, and address bar change. You can configure public results in packaage without writing actions. This is what I wrote in my class.
/DemoJsp3.jsp
package com.struts.app;import com.opensymphony.xwork2.ActionSupport;public class Demo1 extends ActionSupport{private int t;public int getT() {return t;}public void setT(int t) {this.t = t;}@Overridepublic String execute() throws Exception {// TODO Auto-generated method stubif(t==1){return SUCCESS;}else{return "main";}}}
So as long as the input t is not equal to 1, the main is returned. Global-result is called. If you want to call the global-result in another package, you can modify the extends content in the package.
/DemoJsp3.jsp
/DemoJsp1.jsp
/DemoJsp2.jsp
Package rr wants to use hoho's global-result to change extends to hoho. In large projects, many people can inherit a public result, so this method is used.