This is an automated email from the ASF dual-hosted git repository.
git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-site by this push:
new 97e0e2a Updates production by Jenkins
97e0e2a is described below
commit 97e0e2a1f058849352c425c4290e520ef01d30c6
Author: jenkins <[email protected]>
AuthorDate: Mon Oct 2 17:54:55 2017 +0000
Updates production by Jenkins
---
content/core-developers/action-mapper.html | 398 ++++++++---------------------
1 file changed, 112 insertions(+), 286 deletions(-)
diff --git a/content/core-developers/action-mapper.html
b/content/core-developers/action-mapper.html
index 2516538..f537c9d 100644
--- a/content/core-developers/action-mapper.html
+++ b/content/core-developers/action-mapper.html
@@ -127,308 +127,149 @@
<section class="col-md-12">
<a href="index.html" title="back to Core Developers Guide"><< back to Core
Developers Guide</a>
<a class="edit-on-gh"
href="https://github.com/apache/struts-site/edit/master/source/core-developers/action-mapper.md"
title="Edit this page on GitHub">Edit on GitHub</a>
- <h1 id="actionmapper">ActionMapper</h1>
+ <h1 class="no_toc" id="actionmapper">ActionMapper</h1>
+
+<ul id="markdown-toc">
+ <li><a href="#description" id="markdown-toc-description">Description</a></li>
+ <li><a href="#defaultactionmapper"
id="markdown-toc-defaultactionmapper">DefaultActionMapper</a> <ul>
+ <li><a href="#method-prefix" id="markdown-toc-method-prefix">Method
prefix</a></li>
+ <li><a href="#action-prefix" id="markdown-toc-action-prefix">Action
prefix</a></li>
+ <li><a href="#allowed-action-name-regex"
id="markdown-toc-allowed-action-name-regex">Allowed action name RegEx</a></li>
+ <li><a href="#allowed-method-name-regex"
id="markdown-toc-allowed-method-name-regex">Allowed method name RegEx</a></li>
+ </ul>
+ </li>
+ <li><a href="#custom-actionmapper"
id="markdown-toc-custom-actionmapper">Custom ActionMapper</a></li>
+ <li><a href="#compositeactionmapper"
id="markdown-toc-compositeactionmapper">CompositeActionMapper</a></li>
+ <li><a href="#prefixbasedactionmapper"
id="markdown-toc-prefixbasedactionmapper">PrefixBasedActionMapper</a></li>
+ <li><a href="#actionmapper-and-actionmapping-objects"
id="markdown-toc-actionmapper-and-actionmapping-objects">ActionMapper and
ActionMapping objects</a></li>
+ <li><a href="#customize" id="markdown-toc-customize">Customize</a></li>
+</ul>
-<p>####Description####</p>
+<h2 id="description">Description</h2>
<p>The ActionMapper interface provides a mapping between HTTP requests and
action invocation requests and vice-versa.</p>
-<p>When given an HttpServletRequest, the ActionMapper may return null if no
action invocation request matches or it may return an {{ActionMapping}} that
describes an action invocation for the framework to try.</p>
+<p>When given an HttpServletRequest, the ActionMapper may return null if no
action invocation request matches or it may
+return an <code class="highlighter-rouge">ActionMapping</code> that describes
an action invocation for the framework to try.</p>
-<p>The ActionMapper is not required to guarantee that the {{ActionMapping}}
returned be a real action or otherwise ensure a valid request. Accordingly,
most ActionMappers do not need to consult the Struts configuration just to
determine if a request should be mapped.</p>
+<p>The ActionMapper is not required to guarantee that the <code
class="highlighter-rouge">ActionMapping</code> returned be a real action or
otherwise ensure
+a valid request. Accordingly, most ActionMappers do not need to consult the
Struts configuration just to determine if
+a request should be mapped.</p>
-<p>Just as requests can be mapped from HTTP to an action invocation, the
opposite is true as well. However, because HTTP requests (when shown in HTTP
responses) must be in String form, a String is returned rather than an actual
request object.</p>
+<p>Just as requests can be mapped from HTTP to an action invocation, the
opposite is true as well. However, because HTTP
+requests (when shown in HTTP responses) must be in String form, a String is
returned rather than an actual request object.</p>
-<p>####DefaultActionMapper####</p>
+<h2 id="defaultactionmapper">DefaultActionMapper</h2>
-<p>Default action mapper implementation, using the standard</p>
+<p>Default action mapper implementation, using the standard <code
class="highlighter-rouge">*.[ext]</code> (where ext usually
<strong>action</strong>) pattern. The extension
+is looked up from the Struts configuration key <code
class="highlighter-rouge">struts.action.extension</code>.</p>
-<div class="highlighter-rouge"><pre class="highlight"><code>*.[ext]
-</code></pre>
-</div>
-<p> (where ext usually <strong>action</strong>) pattern. The extension is
looked up from the Struts configuration key
{<b>{struts.action.extension}}.</p>
+<p>To help with dealing with buttons and other related requirements, this
mapper (and other <code class="highlighter-rouge">ActionMapper</code>s, we
hope) has
+the ability to name a button with some predefined prefix and have that button
name alter the execution behaviour.</p>
-<p>To help with dealing with buttons and other related requirements, this
mapper (and other {{ActionMapper}}s, we hope) has the ability to name a button
with some predefined prefix and have that button name alter the execution
behaviour. The four prefixes are:</p>
-
-<ul>
- <li>Method prefix - </li>
-</ul>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>method:default
-</code></pre>
-</div>
+<p>The four prefixes are:</p>
<ul>
- <li>Action prefix - </li>
+ <li>Method prefix - <code
class="highlighter-rouge">method:default</code></li>
+ <li>Action prefix - <code
class="highlighter-rouge">action:dashboard</code></li>
</ul>
-<div class="highlighter-rouge"><pre class="highlight"><code>action:dashboard
-</code></pre>
-</div>
-
-<p>In addition to these four prefixes, this mapper also understands the action
naming pattern of</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>foo!bar
-</code></pre>
-</div>
-<p> in either the extension form (eg: </p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>foo!bar.action
-</code></pre>
-</div>
-<p>) or in the prefix form (eg:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>action:foo!bar
-</code></pre>
-</div>
-<p>). This syntax tells this mapper to map to the action named</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>foo
-</code></pre>
-</div>
-<p> and the method</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>bar
-</code></pre>
-</div>
-<p>.</p>
-
-<p>#####Method prefix#####</p>
-
-<p>With method-prefix, instead of calling baz action’s</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>execute()
-</code></pre>
-</div>
-<p> method (by default if it isn’t overridden in</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-<p> to be something else), the baz action’s</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>anotherMethod()
-</code></pre>
-</div>
-<p> will be called. A very elegant way determine which button is clicked.
Alternatively, one would have submit button set a particular value on the
action when clicked, and the</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>execute()
-</code></pre>
-</div>
-<p> method decides on what to do with the setted value depending on which
button is clicked.</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code><!-- START
SNIPPET: method-example -->
-<s:form action="baz">
- <s:textfield label="Enter your name" name="person.name"/>
- <s:submit value="Create person"/>
- <s:submit method="anotherMethod" value="Cancel"/>
-</s:form>
-<!-- END SNIPPET: method-example -->
-</code></pre>
-</div>
-
-<p>#####Action prefix#####</p>
-
-<p>With action-prefix, instead of executing baz action’s</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>execute()
-</code></pre>
-</div>
-<p> method (by default if it isn’t overridden in struts.xml to be something
else), the anotherAction action’s</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>execute()
-</code></pre>
-</div>
-<p> method (assuming again if it isn’t overridden with something else in</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-<p>) will be executed.</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code><!-- START
SNIPPET: action-example -->
-<s:form action="baz">
- <s:textfield label="Enter your name" name="person.name"/>
- <s:submit value="Create person"/>
- <s:submit action="anotherAction" value="Cancel"/>
-</s:form>
-<!-- END SNIPPET: action-example -->
-</code></pre>
-</div>
-
-<p>#####Allowed action name RegEx#####</p>
-
-<p>By default the mapper will check if extracted action name matches provided
RegEx, i.e. </p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>[a-zA-Z0-9._!/\-]*
-</code></pre>
-</div>
-<p>. You redefine this RegEx by defining a constant in </p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-<p>named </p>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.allowed.action.names
-</code></pre>
-</div>
-<p>. If action name doesn’t match the RegEx a default action name will be
returned which is defined as </p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>index
-</code></pre>
-</div>
-<p>. You can also redefine this by specifying constant </p>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.default.action.name
-</code></pre>
-</div>
-<p>in </p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-
-<p>#####Allowed method name RegEx#####</p>
-
-<p>The same logic as above is used for extracted methods, the default RegEx</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>(
-</code></pre>
-</div>
+<p>In addition to these four prefixes, this mapper also understands the action
naming pattern of <code class="highlighter-rouge">foo!bar</code> in either
+the extension form (eg: <code class="highlighter-rouge">foo!bar.action</code>)
or in the prefix form (eg: <code
class="highlighter-rouge">action:foo!bar</code>). This syntax tells this mapper
+to map to the action named <code class="highlighter-rouge">foo</code> and the
method <code class="highlighter-rouge">bar</code>.</p>
-<div class="highlighter-rouge"><pre class="highlight"><code>[a-zA-Z_]*[0-9]*)
-</code></pre>
-</div>
-<p>is used to check if method is allowed, you can change this by setting
constant </p>
+<h3 id="method-prefix">Method prefix</h3>
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.allowed.method.names
-</code></pre>
-</div>
-<p>in </p>
+<p>With method-prefix, instead of calling baz action’s <code
class="highlighter-rouge">execute()</code> method (by default if it isn’t
overridden in <code class="highlighter-rouge">struts.xml</code>
+to be something else), the baz action’s <code
class="highlighter-rouge">anotherMethod()</code> will be called. A very elegant
way determine which button is
+clicked. Alternatively, one would have submit button set a particular value on
the action when clicked, and the <code
class="highlighter-rouge">execute()</code>
+method decides on what to do with the setted value depending on which button
is clicked.</p>
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><s:form</span> <span class="na">action=</span><span
class="s">"baz"</span><span class="nt">></span>
+ <span class="nt"><s:textfield</span> <span
class="na">label=</span><span class="s">"Enter your name"</span> <span
class="na">name=</span><span class="s">"person.name"</span><span
class="nt">/></span>
+ <span class="nt"><s:submit</span> <span class="na">value=</span><span
class="s">"Create person"</span><span class="nt">/></span>
+ <span class="nt"><s:submit</span> <span class="na">method=</span><span
class="s">"anotherMethod"</span> <span class="na">value=</span><span
class="s">"Cancel"</span><span class="nt">/></span>
+<span class="nt"></s:form></span>
</code></pre>
</div>
-<p>. If method doesn’t match the RegEx a default method is returned, i.e. </p>
-<div class="highlighter-rouge"><pre class="highlight"><code>execute
-</code></pre>
-</div>
-<p>. This can be changed by defining constant </p>
+<h3 id="action-prefix">Action prefix</h3>
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.default.method.name
-</code></pre>
-</div>
-<p>in </p>
+<p>With action-prefix, instead of executing baz action’s <code
class="highlighter-rouge">execute()</code> method (by default if it isn’t
overridden in <code class="highlighter-rouge">struts.xml</code>
+to be something else), the anotherAction action’s <code
class="highlighter-rouge">execute()</code> method (assuming again if it isn’t
overridden with something
+else in <code class="highlighter-rouge">struts.xml</code>) will be
executed.</p>
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><s:form</span> <span class="na">action=</span><span
class="s">"baz"</span><span class="nt">></span>
+ <span class="nt"><s:textfield</span> <span
class="na">label=</span><span class="s">"Enter your name"</span> <span
class="na">name=</span><span class="s">"person.name"</span><span
class="nt">/></span>
+ <span class="nt"><s:submit</span> <span class="na">value=</span><span
class="s">"Create person"</span><span class="nt">/></span>
+ <span class="nt"><s:submit</span> <span class="na">action=</span><span
class="s">"anotherAction"</span> <span class="na">value=</span><span
class="s">"Cancel"</span><span class="nt">/></span>
+<span class="nt"></s:form></span>
</code></pre>
</div>
-<p>.</p>
-<p>Please note that this funcionallity only works when <a
href="https://cwiki\.apache\.org/confluence/display/WW/Action\+Configuration\#ActionConfiguration\-DynamicMethodInvocation">Dynamic
Method
Invocation</a>^[https://cwiki.apache.org/confluence/display/WW/Action+Configuration#ActionConfiguration-DynamicMethodInvocation]
is enabled.</p>
+<h3 id="allowed-action-name-regex">Allowed action name RegEx</h3>
-<p>####Custom ActionMapper####</p>
+<p>By default the mapper will check if extracted action name matches provided
RegEx, i.e. <code class="highlighter-rouge">[a-zA-Z0-9._!/-]*</code>. You
redefine
+this RegEx by defining a constant in <code
class="highlighter-rouge">struts.xml</code> named <code
class="highlighter-rouge">struts.allowed.action.names</code>. If action name
doesn’t match
+the RegEx a default action name will be returned which is defined as <code
class="highlighter-rouge">index</code>. You can also redefine this by
specifying
+constant <code class="highlighter-rouge">struts.default.action.name</code> in
<code class="highlighter-rouge">struts.xml</code>.</p>
-<p>You can define your own ActionMapper by implementing</p>
+<h3 id="allowed-method-name-regex">Allowed method name RegEx</h3>
-<div class="highlighter-rouge"><pre
class="highlight"><code>org.apache.struts2.dispatcher.mapper.ActionMapper
-</code></pre>
-</div>
-<p>then configuring Struts 2 to use the new class in struts.xml</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code><bean
type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="mymapper"
class="com.mycompany.myapp.MyActionMapper" />
-<constant name="struts.mapper.class" value="mymapper" />
+<p>The same logic as above is used for extracted methods, the default RegEx
(<code class="highlighter-rouge">[a-zA-Z_]*[0-9]*</code>) is used to check if
method
+is allowed, you can change this by setting constant <code
class="highlighter-rouge">struts.allowed.method.names</code> in <code
class="highlighter-rouge">struts.xml</code>. If method doesn’t match
+the RegEx a default method is returned, i.e. <code
class="highlighter-rouge">execute</code>. This can be changed by defining
constant <code class="highlighter-rouge">struts.default.method.name</code>
+in <code class="highlighter-rouge">struts.xml</code>.</p>
-</code></pre>
-</div>
+<p>Please note that this functionality only works when <a
href="action-configuration.html#dynamic-method-invocation">Dynamic Method
Invocation</a>
+is enabled.</p>
-<p>Possible uses of the ActionMapper include defining your own, cleaner
namespaces, such as URLs like <strong>/person/1</strong>, which would be
similar to a request to <strong>/getPerson.action?personID=1</strong> using the
DefaultActionMapper.</p>
+<h2 id="custom-actionmapper">Custom ActionMapper</h2>
-<p>####CompositeActionMapper####</p>
+<p>You can define your own ActionMapper by implementing <code
class="highlighter-rouge">org.apache.struts2.dispatcher.mapper.ActionMapper</code>
then configuring
+Struts 2 to use the new class in <code
class="highlighter-rouge">struts.xml</code></p>
-<p>A composite action mapper that is capable of delegating to a series of if
the former failed to obtained a valid <em>ActionMapping</em> or uri.</p>
-
-<p>It is configured through <a href="struts-xml.html">struts.xml</a>. For
example, with the following entries in struts.xml</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code><constant
name="struts.mapper.class" value="composite" />
-<constant name="struts.mapper.composite" value="struts,restful,restful2"
/>
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><bean</span> <span class="na">type=</span><span
class="s">"org.apache.struts2.dispatcher.mapper.ActionMapper"</span> <span
class="na">name=</span><span class="s">"mymapper"</span> <span
class="na">class=</span><span
class="s">"com.mycompany.myapp.MyActionMapper"</span> <span
class="nt">/></span>
+<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.class"</span> <span class="na">value=</span><span
class="s">"mymapper"</span> <span class="nt">/></span>
</code></pre>
</div>
-<p>When</p>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper#getMapping(HttpServletRequest,
ConfigurationManager)
-</code></pre>
-</div>
-<p>or</p>
+<p>Possible uses of the ActionMapper include defining your own, cleaner
namespaces, such as URLs like <strong>/person/1</strong>, which
+would be similar to a request to <strong>/getPerson.action?personID=1</strong>
using the DefaultActionMapper.</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper#getUriFromActionMapping(ActionMapping)
-</code></pre>
-</div>
-<p>is invoked,</p>
+<h2 id="compositeactionmapper">CompositeActionMapper</h2>
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper
-</code></pre>
-</div>
-<p>would go through these s in sequence starting from identified by</p>
+<p>A composite action mapper that is capable of delegating to a series of if
the former failed to obtained a valid
+<code class="highlighter-rouge">ActionMapping</code> or uri.</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.mapper.composite.1
-</code></pre>
-</div>
-<p>, followed by</p>
+<p>It is configured through <a href="struts-xml.html">struts.xml</a>. For
example, with the following entries in <code
class="highlighter-rouge">struts.xml</code></p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.mapper.composite.2
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.class"</span> <span class="na">value=</span><span
class="s">"composite"</span> <span class="nt">/></span>
+<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.composite"</span> <span class="na">value=</span><span
class="s">"struts,restful,restful2"</span> <span class="nt">/></span>
</code></pre>
</div>
-<p>and finally</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>struts.mapper.composite.3
-</code></pre>
-</div>
-<p>(in this case) until either one of the return a valid result (not null) or
it runs out of in which case it will just return null for both</p>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper#getMapping(HttpServletRequest,
ConfigurationManager)
-</code></pre>
-</div>
-<p>and</p>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper#getUriFromActionMapping(ActionMapping)
-</code></pre>
-</div>
-<p>methods.</p>
+<p>When <code
class="highlighter-rouge">CompositeActionMapper#getMapping(HttpServletRequest,
ConfigurationManager)</code> or <code
class="highlighter-rouge">CompositeActionMapper#getUriFromActionMapping(ActionMapping)</code>
+is invoked, <code class="highlighter-rouge">CompositeActionMapper</code> would
go through these s in sequence starting from identified by <code
class="highlighter-rouge">struts.mapper.composite.1</code>,
+followed by <code class="highlighter-rouge">struts.mapper.composite.2</code>
and finally <code class="highlighter-rouge">struts.mapper.composite.3</code>
(in this case) until either one of the return
+a valid result (not null) or it runs out of in which case it will just return
null for both
+<code
class="highlighter-rouge">CompositeActionMapper#getMapping(HttpServletRequest,
ConfigurationManager)</code> and <code
class="highlighter-rouge">CompositeActionMapper#getUriFromActionMapping(ActionMapping)</code>
+methods.</p>
<p>For example with the following in struts.xml:</p>
-<div class="highlighter-rouge"><pre class="highlight"><code><constant
name="struts.mapper.class" value="composite" />
-<constant name="struts.mapper.composite" value="struts,restful" />
-
-</code></pre>
-</div>
-
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.class"</span> <span class="na">value=</span><span
class="s">"composite"</span> <span class="nt">/></span>
+<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.composite"</span> <span class="na">value=</span><span
class="s">"struts,restful"</span> <span class="nt">/></span>
</code></pre>
</div>
-<p>will be configured with 2 ActionMapper, namely “struts” which is</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>org.apache.struts2.dispatcher.mapper.DefaultActionMapper
-</code></pre>
-</div>
-<p>and “restful” which is</p>
+<p><code class="highlighter-rouge">CompositeActionMapper</code> will be
configured with 2 ActionMapper, namely “struts” which is <code
class="highlighter-rouge">org.apache.struts2.dispatcher.mapper.DefaultActionMapper</code>
+and “restful” which is <code
class="highlighter-rouge">org.apache.struts2.dispatcher.mapper.RestfulActionMapperRestfulActionMapper</code>.</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>org.apache.struts2.dispatcher.mapper.RestfulActionMapperRestfulActionMapper
-</code></pre>
-</div>
-<p>.</p>
+<p><code class="highlighter-rouge">CompositeActionMapper</code> would consult
each of them in order described above.</p>
-<div class="highlighter-rouge"><pre
class="highlight"><code>CompositeActionMapper
-</code></pre>
-</div>
-<p>would consult each of them in order described above.</p>
-
-<p>####PrefixBasedActionMapper####</p>
+<h2 id="prefixbasedactionmapper">PrefixBasedActionMapper</h2>
<p> <p>
A prefix based action mapper that is capable of delegating to other {@link
ActionMapper}s based on the request's prefix.<br />
@@ -475,54 +316,39 @@
<constant name="struts.mapper.prefixMapping" value="..."/>
</pre></p>
-<p>####ActionMapper and ActionMapping objects####</p>
+<h2 id="actionmapper-and-actionmapping-objects">ActionMapper and ActionMapping
objects</h2>
-<p>The ActionMapper fetches the ActionMapping object corresponding to a given
request. Essentially, the ActionMapping is a data transfer object that collects
together details such as the Action class and method to execute. The mapping is
utilized by the Dispatcher and various user interface components. It is
customizable through</p>
+<p>The ActionMapper fetches the ActionMapping object corresponding to a given
request. Essentially, the ActionMapping is
+a data transfer object that collects together details such as the Action class
and method to execute. The mapping is
+utilized by the Dispatcher and various user interface components. It is
customizable through <code class="highlighter-rouge">struts.mapper.class</code>
+entry in <code class="highlighter-rouge">struts.xml</code>. Note that the
value of this constant is the name of the bean of the new mapper.</p>
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.mapper.class
-</code></pre>
-</div>
-<p>entry in</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.properties
-</code></pre>
-</div>
-<p>or</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-<p>. Note that the value of this constant is the name of the bean of the new
mapper.</p>
-
-<p>#####Customize#####</p>
+<h2 id="customize">Customize</h2>
<p>Custom ActionMapper must implement ActionMapper interface and have a
default constructor.</p>
-<blockquote>
-
-</blockquote>
-
-<div class="highlighter-rouge"><pre class="highlight"><code><bean
type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="mymapper"
class="com.mycompany.myapp.MyActionMapper" />
-<constant name="struts.mapper.class" value="mymapper" />
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="nt"><bean</span> <span class="na">type=</span><span
class="s">"org.apache.struts2.dispatcher.mapper.ActionMapper"</span> <span
class="na">name=</span><span class="s">"mymapper"</span> <span
class="na">class=</span><span
class="s">"com.mycompany.myapp.MyActionMapper"</span> <span
class="nt">/></span>
+<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.class"</span> <span class="na">value=</span><span
class="s">"mymapper"</span> <span class="nt">/></span>
</code></pre>
</div>
-<div class="highlighter-rouge"><pre class="highlight"><code>public class
MyCustomActionMapper implements ActionMapper {
- public ActionMapping getMapping(HttpServletRequest request,
- ConfigurationManager configManager) {
- ....
- }
-
- public String getUriFromActionMapping(ActionMapping mapping) {
- ....
- }
-}
+<div class="highlighter-rouge"><pre class="highlight"><code><span
class="kd">public</span> <span class="kd">class</span> <span
class="nc">MyCustomActionMapper</span> <span class="kd">implements</span> <span
class="n">ActionMapper</span> <span class="o">{</span>
+ <span class="kd">public</span> <span class="n">ActionMapping</span> <span
class="n">getMapping</span><span class="o">(</span><span
class="n">HttpServletRequest</span> <span class="n">request</span><span
class="o">,</span>
+ <span class="n">ConfigurationManager</span>
<span class="n">configManager</span><span class="o">)</span> <span
class="o">{</span>
+ <span class="o">....</span>
+ <span class="o">}</span>
+ <span class="kd">public</span> <span class="n">String</span> <span
class="n">getUriFromActionMapping</span><span class="o">(</span><span
class="n">ActionMapping</span> <span class="n">mapping</span><span
class="o">)</span> <span class="o">{</span>
+ <span class="o">....</span>
+ <span class="o">}</span>
+<span class="o">}</span>
</code></pre>
</div>
-<p>(light-on) See also: <a
href="restful-action-mapper.html">RestfulActionMapper</a></p>
+<blockquote>
+ <p>See also: <a href="restful-action-mapper.html">RestfulActionMapper</a></p>
+</blockquote>
</section>
</article>
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].