Introduction to Packages in Struts.xml configuration

Source: Internet
Author: User

<package name= "Itcast" namespace= "/test" extends= "Struts-default" ><action name= "HelloWorld" class= " Cn.itcast.action.HelloWorldAction "method=" execute "><result name=" Success ">/web-inf/page/hello.jsp</ Result></action> </package>

Using packages in the STRUTS2 framework to manage the action, the role of the package is very similar to the class package in Java, and it is primarily used to manage a set of action related to business functions. In practical applications, we should place a set of actions related to a business function under the same package. When you configure a package, you must specify the Name property, which can be any name, but must be unique, and he does not correspond to the Java class package, which must be referenced by the other package if it is to inherit the package. The namespace property of the package is used to define the namespace of the package, which is part of the path that accesses the action under the package, such as the action for accessing the example above, and the access path is:/test/helloworld.action. The namespace property can not be configured, and for this example, if the property is not specified, the default namespace is "" (an empty string). Usually each package should inherit the Struts-default package, because many of the core features of Struts2 are interceptors. Such as: Package request parameters from the request to action, file upload and data validation, etc. are implemented through the interceptor. Struts-default defines these interceptors and the result type. You can say this: When a package inherits Struts-default, it can use the core functionality provided by STRUTS2. The Struts-default package is defined in the Struts-default.xml in the Struts2-core-2.x.x.jar file. Struts-default.xml is also the STRUTS2 default profile. STRUTS2 automatically loads the Struts-default.xml file every time. Note: Packages can also be defined as abstract packages by abstract= "true", which cannot contain an action in the abstract package.

Introduction to Packages in Struts.xml configuration

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.