<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