Struts 2 reading notes -- search sequence for loading constants in struts 2.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.