Repository: struts-site Updated Branches: refs/heads/asf-site 26bb096d0 -> 47b6ee7b7
Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/47b6ee7b Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/47b6ee7b Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/47b6ee7b Branch: refs/heads/asf-site Commit: 47b6ee7b74f245ad2b9dcfc0d47247aad0de79ce Parents: 26bb096 Author: jenkins <bui...@apache.org> Authored: Mon Jul 31 14:21:57 2017 +0000 Committer: jenkins <bui...@apache.org> Committed: Mon Jul 31 14:21:57 2017 +0000 ---------------------------------------------------------------------- .../namespace-configuration.html | 199 +++++-------------- .../core-developers/package-configuration.html | 118 +++++------ 2 files changed, 107 insertions(+), 210 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/47b6ee7b/content/core-developers/namespace-configuration.html ---------------------------------------------------------------------- diff --git a/content/core-developers/namespace-configuration.html b/content/core-developers/namespace-configuration.html index 1fd6938..b82e9f9 100644 --- a/content/core-developers/namespace-configuration.html +++ b/content/core-developers/namespace-configuration.html @@ -126,170 +126,79 @@ <a href="index.html" title="back to Core Developers Guide"><< back to Core Developers Guide</a> <h1 id="namespace-configuration">Namespace Configuration</h1> -<p>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.</p> +<p>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.</p> -<table> - <tbody> - <tr> - <td>Struts 2 Namespaces are the equivalent of Struts Action 1 modules, but more convenient and flexible.</td> - </tr> - </tbody> -</table> +<blockquote> + <p>Struts 2 Namespaces are the equivalent of Struts Action 1 modules, but more convenient and flexible.</p> +</blockquote> -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> +<h2 id="default-namespace">Default Namespace</h2> -<p>#####Default Namespace#####</p> +<p>The default namespace is <code class="highlighter-rouge">""</code> - 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.</p> -<p>The default namespace is</p> +<p>The namespace prefix can be registered with Java declarative security, to ensure only authorized users can access +the actions in a given namespace.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>"" -</code></pre> -</div> -<p>- 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.</p> - -<p>The namespace prefix can be registered with Java declarative security, to ensure only authorized users can access the actions in a given namespace.</p> - -<p>#####Root Namespace#####</p> - -<p>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.</p> - -<p>#####Namespace Example#####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -<package name="default"> - <action name="foo" class="mypackage.simpleAction"> - <result name="success" type="dispatcher">greeting.jsp</result> - </action> - - <action name="bar" class="mypackage.simpleAction"> - <result name="success" type="dispatcher">bar1.jsp</result> - </action> -</package> - -<package name="mypackage1" namespace="/"> - <action name="moo" class="mypackage.simpleAction"> - <result name="success" type="dispatcher">moo.jsp</result> - </action> -</package> +<h2 id="root-namespace">Root Namespace</h2> -<package name="mypackage2" namespace="/barspace"> - <action name="bar" class="mypackage.simpleAction"> - <result name="success" type="dispatcher">bar2.jsp</result> - </action> -</package> +<p>A root namespace <code class="highlighter-rouge">"/"</code> 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 <code class="highlighter-rouge">""</code> namespace if a local action is not found.</p> -</code></pre> -</div> - -<p>#####How the Code Works#####</p> +<h2 id="namespace-example">Namespace Example</h2> -<p>If a request for</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>/barspace/bar.action -</code></pre> -</div> -<p>is made, the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>/barspace -</code></pre> -</div> -<p>namespace is searched for the</p> +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><package</span> <span class="na">name=</span><span class="s">"default"</span><span class="nt">></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"foo"</span> <span class="na">class=</span><span class="s">"mypackage.simpleAction"</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"success"</span> <span class="na">type=</span><span class="s">"dispatcher"</span><span class="nt">></span>greeting.jsp<span class="nt"></result></span> + <span class="nt"></action></span> -<div class="highlighter-rouge"><pre class="highlight"><code>bar -</code></pre> -</div> -<p>action. If found, the</p> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"bar"</span> <span class="na">class=</span><span class="s">"mypackage.simpleAction"</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"success"</span> <span class="na">type=</span><span class="s">"dispatcher"</span><span class="nt">></span>bar1.jsp<span class="nt"></result></span> + <span class="nt"></action></span> +<span class="nt"></package></span> -<div class="highlighter-rouge"><pre class="highlight"><code>bar -</code></pre> -</div> -<p>action is executed, else it will fall back to the default namespace. In the Namespace Example, the</p> +<span class="nt"><package</span> <span class="na">name=</span><span class="s">"mypackage1"</span> <span class="na">namespace=</span><span class="s">"/"</span><span class="nt">></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"moo"</span> <span class="na">class=</span><span class="s">"mypackage.simpleAction"</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"success"</span> <span class="na">type=</span><span class="s">"dispatcher"</span><span class="nt">></span>moo.jsp<span class="nt"></result></span> + <span class="nt"></action></span> +<span class="nt"></package></span> -<div class="highlighter-rouge"><pre class="highlight"><code>bar +<span class="nt"><package</span> <span class="na">name=</span><span class="s">"mypackage2"</span> <span class="na">namespace=</span><span class="s">"/barspace"</span><span class="nt">></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"bar"</span> <span class="na">class=</span><span class="s">"mypackage.simpleAction"</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"success"</span> <span class="na">type=</span><span class="s">"dispatcher"</span><span class="nt">></span>bar2.jsp<span class="nt"></result></span> + <span class="nt"></action></span> +<span class="nt"></package></span> </code></pre> </div> -<p>action does exist in the</p> -<div class="highlighter-rouge"><pre class="highlight"><code>/barspace -</code></pre> -</div> -<p>namespace, so the</p> +<h3 id="how-the-code-works">How the Code Works</h3> -<div class="highlighter-rouge"><pre class="highlight"><code>bar -</code></pre> -</div> -<p>action will be executed, and if âsuccessâ is returned, the request will be forwarded to</p> +<p>If a request for <code class="highlighter-rouge">/barspace/bar.action</code> is made, the <code class="highlighter-rouge">/barspace</code> namespace is searched for the <code class="highlighter-rouge">bar</code> action. +If found, the <code class="highlighter-rouge">bar</code> action is executed, else it will fall back to the default namespace. In the Namespace Example, +the <code class="highlighter-rouge">bar</code> action does exist in the <code class="highlighter-rouge">/barspace</code> namespace, so the <code class="highlighter-rouge">bar</code> action will be executed, and if âsuccessâ is +returned, the request will be forwarded to <code class="highlighter-rouge">bar2.jsp</code>.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>bar2.jsp -</code></pre> -</div> -<p>.</p> - -<table> - <tbody> - <tr> - <td>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.</td> - </tr> - </tbody> -</table> - -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> - -<p>In the Namespace Example, if a request for</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>moo.action -</code></pre> -</div> -<p>is made, the root namespace (â/â) is searched for a</p> +<p>If a request is made to <code class="highlighter-rouge">/barspace/foo.action</code>, the namespace <code class="highlighter-rouge">/barspace</code> will be checked for action <code class="highlighter-rouge">foo</code>. +If a local action is not found, the default namespace is checked. In the Namespace Example, there is no action <code class="highlighter-rouge">foo</code> +in the namespace <code class="highlighter-rouge">/barspace</code>, therefore the default will be checked and <code class="highlighter-rouge">/foo.action</code> will be executed.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>moo -</code></pre> -</div> -<p>action; if a root action is not found, the default namespace is checked. In this case, the</p> +<p>In the Namespace Example, if a request for <code class="highlighter-rouge">moo.action</code> is made, the root namespace <code class="highlighter-rouge">"/"</code> is searched for a <code class="highlighter-rouge">moo</code> +action; if a root action is not found, the default namespace is checked. In this case, the <code class="highlighter-rouge">moo</code> action does exist +and will be executed. Upon success, the request would be forwarded to <code class="highlighter-rouge">bar2.jsp</code>.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>moo -</code></pre> -</div> -<p>action does exist and will be executed. Upon success, the request would be forwarded to</p> +<p>If a request is made for <code class="highlighter-rouge">/foo.action</code>, the root <code class="highlighter-rouge">"/"</code> namespace will be checked. If <code class="highlighter-rouge">foo</code> is found, the root action +will be selected. Otherwise, the framework will check the default namespace. In the Namespace Example, the <code class="highlighter-rouge">foo</code> action +does not exist in the root namespace, so the default namespace is checked, and the default foo action is executed.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>bar2.jsp -</code></pre> -</div> -<p>.</p> - -<table> - <tbody> - <tr> - <td>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.</td> - </tr> - </tbody> -</table> - -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> - -<p>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.</p> - -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> +<p>Namespace are not hierarchical like a file system path. There is one namespace level. For example if the URL +<code class="highlighter-rouge">/barspace/myspace/bar.action</code> is requested, the framework will first look for namespace <code class="highlighter-rouge">/barspace/myspace</code>. +If the action does not exist at <code class="highlighter-rouge">/barspace/myspace</code>, the search will immediately fall back to the default namespace <code class="highlighter-rouge">""</code>. +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.</p> </section> </article> http://git-wip-us.apache.org/repos/asf/struts-site/blob/47b6ee7b/content/core-developers/package-configuration.html ---------------------------------------------------------------------- diff --git a/content/core-developers/package-configuration.html b/content/core-developers/package-configuration.html index 90f8440..9197753 100644 --- a/content/core-developers/package-configuration.html +++ b/content/core-developers/package-configuration.html @@ -126,30 +126,22 @@ <a href="index.html" title="back to Core Developers Guide"><< back to Core Developers Guide</a> <h1 id="package-configuration">Package Configuration</h1> -<p>Packages are a way to group actions, results, result types, interceptors, and interceptor-stacks into a logical configuration unit. Conceptually, packages are similiar to objects in that they can be extended and have individual parts that can be overridden by âsubâ packages.</p> +<p>Packages are a way to group actions, results, result types, interceptors, and interceptor-stacks into a logical +configuration unit. Conceptually, packages are similar to objects in that they can be extended and have individual +parts that can be overridden by âsubâ packages.</p> -<p>#####Packages#####</p> +<h2 id="packages">Packages</h2> -<p>The package element has one required attribute,</p> +<p>The package element has one required attribute <code class="highlighter-rouge">name</code>, which acts as the key for later reference to the package. +The <code class="highlighter-rouge">extends</code> attribute is optional and allows one package to inherit the configuration of one or more previous packages +- including all interceptor, interceptor-stack, and action configurations.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>name -</code></pre> -</div> -<p>, which acts as the key for later reference to the package. The</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>extends -</code></pre> -</div> -<p>attribute is optional and allows one package to inherit the configuration of one or more previous packages - including all interceptor, interceptor-stack, and action configurations.</p> - -<p>(!) Note that the configuration file is processed sequentially down the document, so the package referenced by an âextendsâ should be defined <em>above</em> the package which extends it.</p> +<blockquote> + <p>Note that the configuration file is processed sequentially down the document, so the package referenced +by an âextendsâ should be defined <em>above</em> the package which extends it.</p> +</blockquote> -<p>The optional</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>abstract -</code></pre> -</div> -<p>attribute creates a base package that can omit the action configuration.</p> +<p>The optional <code class="highlighter-rouge">abstract</code> attribute creates a base package that can omit the action configuration.</p> <table> <thead> @@ -173,7 +165,7 @@ <tr> <td>namespace</td> <td>no</td> - <td>see <a href="#PAGE_14276">Namespace Configuration</a></td> + <td>see <a href="namespace-configuration.html">Namespace Configuration</a></td> </tr> <tr> <td>abstract</td> @@ -183,61 +175,57 @@ </tbody> </table> -<p><strong>Simple usage</strong></p> +<h3 id="simple-usage">Simple usage</h3> <p><strong>Package Example (struts.xml)</strong></p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<struts> - <package name="employee" extends="struts-default" namespace="/employee"> - <default-interceptor-ref name="crudStack"/> - - <action name="list" method="list" - class="org.apache.struts2.showcase.action.EmployeeAction" > - <result>/empmanager/listEmployees.jsp</result> - <interceptor-ref name="basicStack"/> - </action> - <action name="edit-*" class="org.apache.struts2.showcase.action.EmployeeAction"> - <param name="empId">{1}</param> - <result>/empmanager/editEmployee.jsp</result> - <interceptor-ref name="crudStack"> - <param name="validation.excludeMethods">execute</param> - </interceptor-ref> - </action> - <action name="save" method="save" - class="org.apache.struts2.showcase.action.EmployeeAction" > - <result name="input">/empmanager/editEmployee.jsp</result> - <result type="redirect">edit-${currentEmployee.empId}.action</result> - </action> - <action name="delete" method="delete" - class="org.apache.struts2.showcase.action.EmployeeAction" > - <result name="error">/empmanager/editEmployee.jsp</result> - <result type="redirect">edit-${currentEmployee.empId}.action</result> - </action> - </package> -</struts> - +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><struts></span> + <span class="nt"><package</span> <span class="na">name=</span><span class="s">"employee"</span> <span class="na">extends=</span><span class="s">"struts-default"</span> <span class="na">namespace=</span><span class="s">"/employee"</span><span class="nt">></span> + <span class="nt"><default-interceptor-ref</span> <span class="na">name=</span><span class="s">"crudStack"</span><span class="nt">/></span> + + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"list"</span> <span class="na">method=</span><span class="s">"list"</span> + <span class="na">class=</span><span class="s">"org.apache.struts2.showcase.action.EmployeeAction"</span> <span class="nt">></span> + <span class="nt"><result></span>/empmanager/listEmployees.jsp<span class="nt"></result></span> + <span class="nt"><interceptor-ref</span> <span class="na">name=</span><span class="s">"basicStack"</span><span class="nt">/></span> + <span class="nt"></action></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"edit-*"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.showcase.action.EmployeeAction"</span><span class="nt">></span> + <span class="nt"><param</span> <span class="na">name=</span><span class="s">"empId"</span><span class="nt">></span>{1}<span class="nt"></param></span> + <span class="nt"><result></span>/empmanager/editEmployee.jsp<span class="nt"></result></span> + <span class="nt"><interceptor-ref</span> <span class="na">name=</span><span class="s">"crudStack"</span><span class="nt">></span> + <span class="nt"><param</span> <span class="na">name=</span><span class="s">"validation.excludeMethods"</span><span class="nt">></span>execute<span class="nt"></param></span> + <span class="nt"></interceptor-ref></span> + <span class="nt"></action></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"save"</span> <span class="na">method=</span><span class="s">"save"</span> + <span class="na">class=</span><span class="s">"org.apache.struts2.showcase.action.EmployeeAction"</span> <span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"input"</span><span class="nt">></span>/empmanager/editEmployee.jsp<span class="nt"></result></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"redirect"</span><span class="nt">></span>edit-${currentEmployee.empId}.action<span class="nt"></result></span> + <span class="nt"></action></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"delete"</span> <span class="na">method=</span><span class="s">"delete"</span> + <span class="na">class=</span><span class="s">"org.apache.struts2.showcase.action.EmployeeAction"</span> <span class="nt">></span> + <span class="nt"><result</span> <span class="na">name=</span><span class="s">"error"</span><span class="nt">></span>/empmanager/editEmployee.jsp<span class="nt"></result></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"redirect"</span><span class="nt">></span>edit-${currentEmployee.empId}.action<span class="nt"></result></span> + <span class="nt"></action></span> + <span class="nt"></package></span> +<span class="nt"></struts></span> </code></pre> </div> -<p><strong>Inherit from more than one package</strong></p> +<h3 id="inherit-from-more-than-one-package">Inherit from more than one package</h3> <p><strong>Multi package Example (struts.xml)</strong></p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<struts> - <package name="employee" extends="struts-default, json-default" namespace="/employee"> - - <action name="list" method="list" class="org.apache.struts2.showcase.action.EmployeeAction" > - <result>/empmanager/listEmployees.jsp</result> - <result type="json"> - <param name="root">employees</param> - </result> - </action> +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><struts></span> + <span class="nt"><package</span> <span class="na">name=</span><span class="s">"employee"</span> <span class="na">extends=</span><span class="s">"struts-default, json-default"</span> <span class="na">namespace=</span><span class="s">"/employee"</span><span class="nt">></span> - </package> -</struts> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"list"</span> <span class="na">method=</span><span class="s">"list"</span> <span class="na">class=</span><span class="s">"org.apache.struts2.showcase.action.EmployeeAction"</span> <span class="nt">></span> + <span class="nt"><result></span>/empmanager/listEmployees.jsp<span class="nt"></result></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"json"</span><span class="nt">></span> + <span class="nt"><param</span> <span class="na">name=</span><span class="s">"root"</span><span class="nt">></span>employees<span class="nt"></param></span> + <span class="nt"></result></span> + <span class="nt"></action></span> + <span class="nt"></package></span> +<span class="nt"></struts></span> </code></pre> </div>