1 Namespace determines the action access path. The default value is "", which can receive actions in all paths.2 Namespace can be written as/,/XXX, or/XXX/yyy. The access path of the corresponding action is/index. Action,3 /XXX/index. Action, or/XXX/YYY/index. Action.4Namespace should also be named by modules.
1 <? XML version = "1.0" encoding = "UTF-8" ?> 2 <! Doctype struts public 3 "-// Apache Software Foundation // DTD struts configuration 2.0 // en" 4 Http://struts.apache.org/dtds/struts-2.0.dtd" > 5 6 < Struts > 7 < Constant Name = "Struts. devmode" Value = "True" /> 8 9 <! -- In the package below, the namespace is/front. To access the index, enter./Front/index in the browser. --> 10 < Package Name = "Front" Extends = "Struts-Default" Namespace = "/Front" > 11 < Action Name = "Index" > 12 < Result > /Namespace. jsp </ Result > 13 </ Action > 14 </ Package > 15 <! -- In the package below, the namespace is empty. Access the index and enter the index in the browser. No matter whether there are other addresses in front, this is about the search order. --> 16 < Package Name = "Main" Extends = "Struts-Default" Namespace = "" > 17 < Action Name = "Index" > 18 < Result > /Namespace. jsp </ Result > 19 <! -- If the attribute is not written, the default value is success. --> 20 </ Action > 21 </ Package > 22 23 </ Struts >
1. Obtain the URI of the Request Path. For example, the URL is http: // server/struts2/path1/path2/path3/test. Action.
2. first, find the package whose namespace is/path1/path2/path3. If this package exists, search for the action named test in this package. If this package does not exist, go to step 3;
3. Find the package whose namespace is/path1/path2. If this package exists, search for the action named test in this package. If this package does not exist, go to step 4;
4. Find the package whose namespace is/path1. If the package exists, search for the action named test in the package. If the package still does not exist, step 5
5. Go to the default namaspace, that is, find the action named test under the package with an empty namespace. If the action still cannot be found, the page prompts that the action cannot be found.