Suppose our access address is: http: // localhost: 8080/struts2/test/helloworld, then change it to http: // localhost: 8080/structs2/test/SDF/SFS/AAA/helloworld can still be accessed?
The answer is yes.
Strange. Why?
Let's take a look at the search sequence of action names.
1. Obtain the URI of the Request Path. For example, the URL is http: // server/struts2./Path1/path2/path3/Test. Action
2. First, find the namespace/Path1/path2/path3If the package does not exist, perform Step 3. If the package exists, search for the action named test in the package, when no action is found in the package, the action is directly searched in the package of the default namaspace (the default namespace is an empty string "").If the action cannot be found in the package of the default namaspace, the page prompts that the action cannot be found.
3. Find the namespace/Path1/path2If the package does not exist, go to Step 4. If the package exists, find the action named test in the package, when no action is found in the package, the system will directly go to the default namaspace package to find the action named test,The action cannot be found in the package of the default namaspace. The page prompts that the action cannot be found.
4. Find the namespace/Path1If the package does not exist, perform Step 5. If the package exists, search for the action named test in the package, when no action is found in the package, the system will directly go to the default namaspace package to find the action named test,The action cannot be found in the package of the default namaspace. The page prompts that the action cannot be found.
5. Find the package whose namespace is/. If this package exists, search for the action named test in this package,When the action cannot be found in the package or the package does not exist, the action will be searched in the package of the default namaspace. If the action still cannot be found, the page prompts that the action cannot be found..
Let's take a look at the default values in action:
action name =" helloworld " class =" com. jim. action. helloworldaction " method =" execute " >
result name =" success " >/WEB-INF/page/hello. JSP result >
action >
1> if no class is specified for action, actionsupport is used by default.
2> if no method is specified for the action, the execute () method in the action is executed by default.
3> If the name attribute of result is not specified, the default value is success.
Therefore, if we write:
<ActionName= "Test">
<Result>/WEB-INF/page/Hello. jsp</Result>
</Action>
when we access the action test, it will automatically jump to the following JSP page