Repository: struts-site Updated Branches: refs/heads/master ad23e37fa -> cf8b3e1f8
Cleans up exported page Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/bbbbf10e Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/bbbbf10e Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/bbbbf10e Branch: refs/heads/master Commit: bbbbf10eae7fe21d9d87f1db9c3ac615009845c7 Parents: ad23e37 Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Mon Jul 31 16:18:48 2017 +0200 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Mon Jul 31 16:18:48 2017 +0200 ---------------------------------------------------------------------- .../core-developers/namespace-configuration.md | 135 +++++-------------- 1 file changed, 36 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/bbbbf10e/source/core-developers/namespace-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/namespace-configuration.md b/source/core-developers/namespace-configuration.md index efcbf90..91212b6 100644 --- a/source/core-developers/namespace-configuration.md +++ b/source/core-developers/namespace-configuration.md @@ -5,35 +5,31 @@ title: Namespace Configuration # Namespace Configuration -The namespace attribute subdivides action configurations into logical modules, each with its own identifying prefix\. Namespaces avoid conflicts between action names\. Each namespace can have its own "menu" or "help" action, each with its own implementation\. While the prefix appears in the browser URI, the tags are "namespace aware", so the namespace prefix does not need to be embedded in forms and links\. +The namespace attribute subdivides action configurations into logical modules, each with its own identifying prefix. +Namespaces avoid conflicts between action names. Each namespace can have its own "menu" or "help" action, each with +its own implementation. While the prefix appears in the browser URI, the tags are "namespace aware", so the namespace +prefix does not need to be embedded in forms and links. +> Struts 2 Namespaces are the equivalent of Struts Action 1 modules, but more convenient and flexible. -| Struts 2 Namespaces are the equivalent of Struts Action 1 modules, but more convenient and flexible\. +## Default Namespace -| +The default namespace is `""` - an empty string. The default namespace is used as a "catch-all" namespace. If an action +configuration is not found in a specified namespace, the default namespace is also be searched. The local/global +strategy allows an application to have global action configurations outside of the action element "extends" hierarchy. -#####Default Namespace##### +The namespace prefix can be registered with Java declarative security, to ensure only authorized users can access +the actions in a given namespace. -The default namespace is +## Root Namespace -~~~~~~~ -"" -~~~~~~~ - \- an empty string\. The default namespace is used as a "catch\-all" namespace\. If an action configuration is not found in a specified namespace, the default namespace is also be searched\. The local/global strategy allows an application to have global action configurations outside of the action element "extends" hierarchy\. +A root namespace `"/"` is also supported. The root is the namespace when a request directly under the context path is +received. As with other namespaces, it will fall back to the default `""` namespace if a local action is not found. -The namespace prefix can be registered with Java declarative security, to ensure only authorized users can access the actions in a given namespace\. - -#####Root Namespace##### - -A root namespace ("/") is also supported\. The root is the namespace when a request directly under the context path is received\. As with other namespaces, it will fall back to the default ("") namespace if a local action is not found\. - -#####Namespace Example##### - - - -~~~~~~~ +## Namespace Example +```xml <package name="default"> <action name="foo" class="mypackage.simpleAction"> <result name="success" type="dispatcher">greeting.jsp</result> @@ -55,88 +51,29 @@ A root namespace ("/") is also supported\. The root is the namespace when a requ <result name="success" type="dispatcher">bar2.jsp</result> </action> </package> +``` -~~~~~~~ - -#####How the Code Works##### - -If a request for - -~~~~~~~ -/barspace/bar.action -~~~~~~~ - is made, the - -~~~~~~~ -/barspace -~~~~~~~ - namespace is searched for the - -~~~~~~~ -bar -~~~~~~~ - action\. If found, the - -~~~~~~~ -bar -~~~~~~~ - action is executed, else it will fall back to the default namespace\. In the Namespace Example, the - -~~~~~~~ -bar -~~~~~~~ - action does exist in the - -~~~~~~~ -/barspace -~~~~~~~ - namespace, so the - -~~~~~~~ -bar -~~~~~~~ - action will be executed, and if "success" is returned, the request will be forwarded to - -~~~~~~~ -bar2.jsp -~~~~~~~ -\. - - - -| If a request is made to /barspace/foo\.action, the namespace /barspace will be checked for action foo\. If a local action is not found, the default namespace is checked\. In the Namespace Example, there is no action foo in the namespace /barspace, therefore the default will be checked and /foo\.action will be executed\. - -| - -In the Namespace Example, if a request for - -~~~~~~~ -moo.action -~~~~~~~ - is made, the root namespace ('/') is searched for a - -~~~~~~~ -moo -~~~~~~~ - action; if a root action is not found, the default namespace is checked\. In this case, the - -~~~~~~~ -moo -~~~~~~~ - action does exist and will be executed\. Upon success, the request would be forwarded to - -~~~~~~~ -bar2.jsp -~~~~~~~ -\. - - +### How the Code Works -| If a request is made for /foo\.action, the root / namespace will be checked\. If foo is found, the root action will be selected\. Otherwise, the framework will check the default namespace\. In the Namespace Example, the foo action does not exist in the root namespace, so the default namespace is checked, and the default foo action is executed\. +If a request for `/barspace/bar.action` is made, the `/barspace` namespace is searched for the `bar` action. +If found, the `bar` action is executed, else it will fall back to the default namespace. In the Namespace Example, +the `bar` action does exist in the `/barspace` namespace, so the `bar` action will be executed, and if "success" is +returned, the request will be forwarded to `bar2.jsp`. -| +If a request is made to `/barspace/foo.action`, the namespace `/barspace` will be checked for action `foo`. +If a local action is not found, the default namespace is checked. In the Namespace Example, there is no action `foo` +in the namespace `/barspace`, therefore the default will be checked and `/foo.action` will be executed. +In the Namespace Example, if a request for `moo.action` is made, the root namespace `"/"` is searched for a `moo` +action; if a root action is not found, the default namespace is checked. In this case, the `moo` action does exist +and will be executed. Upon success, the request would be forwarded to `bar2.jsp`. -Namespace are not hierarchical like a file system path\. There is one namespace level\. For example if the URL /barspace/myspace/bar\.action is requested, the framework will first look for namespace /barspace/myspace\. If the action does not exist at /barspace/myspace, the search will immediately fall back to the default namespace ""\. The framework will not parse the namespace into a series of "folders"\. In the Namespace Example, the bar action in the default namespace would be selected\. +If a request is made for `/foo.action`, the root `"/"` namespace will be checked. If `foo` is found, the root action +will be selected. Otherwise, the framework will check the default namespace. In the Namespace Example, the `foo` action +does not exist in the root namespace, so the default namespace is checked, and the default foo action is executed. -| \ No newline at end of file +Namespace are not hierarchical like a file system path. There is one namespace level. For example if the URL +`/barspace/myspace/bar.action` is requested, the framework will first look for namespace `/barspace/myspace`. +If the action does not exist at `/barspace/myspace`, the search will immediately fall back to the default namespace `""`. +The framework will not parse the namespace into a series of "folders". In the Namespace Example, the bar action +in the default namespace would be selected.