1. In the order of actions, the Action of the package under the specified name will be searched first. If no action is found, the action under the package in the default path will be searched.
2. if no value is set for action, action has some default values. If no class is specified, the default value is ActionSupport. If no method is specified, the default value is execute, if the result attribute is not specified, the success attribute is used by default.
3. <package name = "aa" namespace = "/test" extends = "struts-default">
<Action name = "fish">
<Result>/index. jsp </result>
</Action>
</Package>
Use the default value to achieve a simple jump
3. Various forwarding types of results: dispatcher (default); redirect (redirection) Jump to jsp here, But jsp cannot be in the web-inf path; redirectAction,; plainText
,
4. What is redirection?
Redirection is a special page that provides a mechanism for people to enter the entry or click an internal link pointing to the name, the system can automatically navigate to another relevant page specified in the redirection page, so that the relevant page can be accessed by multiple names. For example, if you set a redirection page pointing to "Australia" named "Australia", anyone can enter the "Australia" name into the Australian entry.
During website construction, we often encounter webpage redirection:
1. Website adjustment (for example, modifying the webpage directory structure );
2. The webpage is moved to a new address;
3.modify the extension name of the web page (for example, change ".php" to ".html" or ".shtml ).
5. <global-results> This is a global attempt.
6. <action name = "redfish">
<Result type = "redirect">/index. jsp </result>
</Action>
This is the redirection usage.
This is the Test. Java file.
Packagecom. fish;
Public class Test {
PrivateString username;
PublicString getUsername (){
Return username;
}
Public void setUsername (String username ){
This. username = username;
}
PublicString execute (){
Return "success ";
}
}
This is a struts2.XML file.
<Package name = "fish" namespace = "/test" extends = "struts-default">
<Action name = "redfish" class = "com. fish. Test" method = "execute">
<Param name = "username"> JOHN </param> // you can set the username value by getting the node.
<Result name = "success">
/MyJsp. jsp
</Result>
</Action>
In jsp, we can use the el expression to obtain
The value in $ (username) is John
Next let's add a paragraph in struts2.xml
<Action name = "aa">
<Result type = "redirectAction"> redfish </result>
</Action>
With this action, we can call the view in the above refish, and redirectAction can be another view.
We are adding a sentence,
<Action name = "bb">
<Result type = "redirect">/index. jsp </result>
</Action>
Through this, We can redirect him. Redirection changes the page path in the browser and points to the path of the actually existing jsp or action.