Create a struts 2 project named struts2 and configure the Action according to the following xml.
1 <package name="hello" namespace="/action" extends="struts-default">2 <action name="helloworld" class="com.struts.action.HelloWorldAction" method="execute">3 <result name="success">/WEB-INF/test/hello.jsp</result>4 </action>5 </package>
To deploy an application, we generally access our Action in this way. Http: // localhost: 8080/struts2/test/. helloword
However, when we access the following path: http: // localhost: 8080/struts2/test/sdf/dsf/32/d/helloworld, we can still access the Action.
This is related to the search order of Action names.
Assume that the following path is obtained: http: // localhost: 8080/struts2/path1/path2/path3/test. When struts2 is loaded, first find the package whose namespace is path1/path2/path2. If this package does not exist, search for the package whose namespace is path1/path2. If the package still does not exist, search for the package whose namespace is path1. If the package still does not exist, find the package whose namespace is. If the package does not exist at the end, the action will be searched for in the default namespace package. If you still cannot find the action, the page will prompt that the action cannot be found. If such a package exists in the preceding step, the action named test will be searched for in the package. If this action does not exist in the package, the package named test is searched for in the default namespace. If you still do not save it, the page will prompt you that the action cannot be found.
Read Li Gang's lightweight java EE Enterprise Application Practice (Third edition)-struts 2 + Spring 3 + Hibernate Integrated Development