Detailed explanation of Struts2 Package properties

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	<!-- Set development mode -->
	<constant name="struts.devMode" value="true"/>
	<!--
		Package element: It is a package that defines a struts, which manages the configuration file according to the object-oriented idea. Sub-module development.
			name attribute: Specifies the name of the package. Note: The name of the package is unique within the configuration file.
			extends property: Specifies the parent package of the current package. It is the embodiment of object-oriented management.
			abstract attribute: declares the package as an abstract package. Abstract packages are used to be inherited. Only packages without action elements can be defined as abstract packages
			namespace attribute: namespace. When the namespace is specified, the access path becomes:
							access path = namespace + action name
						  When this property is not specified, the property has a default value, which is "". Note, not "/"!!!!!!!!
						Namespace search order:
							Step 1: First find the corresponding namespace
									Found under the specified namespace: perform the second step.
									Not found under the specified namespace: trace up the namespace structure, all the way to the root namespace, as long as it is found at any level, go to step 2
							Step 2: Find the action name
									First, search for the corresponding action name in the specified namespace: if found, execute the action method of the action class.
									No corresponding action name was found in the specified namespace: Go to the default namespace and look for the action name. Note: it only looks for the action name.
	-->
	<package name="p1" extends="struts-default" namespace="/user">
		<!-- <action name="action1" class="com.itheima.web.action.Demo1Action" method="saveUser" >
			<result name="success">/success.jsp</result>
		</action> -->
	</package>
	
	<package name="p2" extends="struts-default">
		<action name="action2" class="com.itheima.web.action.Demo1Action" method="saveUser2" >
			<result name="success">/success.jsp</result>
		</action>
	</package>
</struts>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326625886&siteId=291194637