struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1015783 [2/2] - in /websites/production/struts/content/core-developers: action-configuration.html annotations.html bean-configuration.html configuration-elements.html constant-configuration.html wildcard-mappings.html
Date Fri, 21 Jul 2017 12:44:35 GMT
Modified: websites/production/struts/content/core-developers/wildcard-mappings.html
==============================================================================
--- websites/production/struts/content/core-developers/wildcard-mappings.html (original)
+++ websites/production/struts/content/core-developers/wildcard-mappings.html Fri Jul 21 12:44:35
2017
@@ -124,255 +124,210 @@
 <article class="container">
   <section class="col-md-12">
     <a href="index.html" title="back to Core Developers Guide"><< back to Core
Developers Guide</a>
-    <h1 id="wildcard-mappings">Wildcard Mappings</h1>
+    <h1 class="no_toc" id="wildcard-mappings">Wildcard Mappings</h1>
 
-<p>#####Wildcards#####</p>
+<ul id="markdown-toc">
+  <li><a href="#wildcards" id="markdown-toc-wildcards">Wildcards</a></li>
+  <li><a href="#parameters-in-namespaces" id="markdown-toc-parameters-in-namespaces">Parameters
in namespaces</a></li>
+  <li><a href="#parameters-after-the-action-name" id="markdown-toc-parameters-after-the-action-name">Parameters
after the action name</a></li>
+  <li><a href="#advanced-wildcards" id="markdown-toc-advanced-wildcards">Advanced
Wildcards</a></li>
+</ul>
 
-<p>As an application grows in size, so will the number of action mappings. Wildcards
can be used to combine similar mappings into one more generic mapping.</p>
+<h2 id="wildcards">Wildcards</h2>
 
-<p>The best way to explain wildcards is to show an example and walk through how it
works. This example modifies a conventional mapping to use wildcards to match all pages that
start with /edit:</p>
+<p>As an application grows in size, so will the number of action mappings. Wildcards
can be used to combine similar 
+mappings into one more generic mapping.</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;action name="/edit*" class="org.apache.struts.webapp.example.Edit{1}Action"&gt;
-    &lt;result name="failure"&gt;/mainMenu.jsp&lt;/result&gt;
-    &lt;result&gt;{1}.jsp&lt;/result&gt;
-&lt;/action&gt;
+<p>The best way to explain wildcards is to show an example and walk through how it
works. This example modifies 
+a conventional mapping to use wildcards to match all pages that start with <code class="highlighter-rouge">/edit</code>:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"/edit*"</span> <span
class="na">class=</span><span class="s">"org.apache.struts.webapp.example.Edit{1}Action"</span><span
class="nt">&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"failure"</span><span class="nt">&gt;</span>/mainMenu.jsp<span
class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;result&gt;</span>{1}.jsp<span class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
-<p>The “*” in the name attribute allows the mapping to match the request
URIs /editSubscription, editRegistration, or any other URI that starts with /edit, however
/editSubscription/add would not be matched. The part of the URI matched by the wildcard will
then be substituted into various attributes of the action mapping and its action results replacing
{1}. For the rest of the request, the framework will see the action mapping and its action
results containing the new values.</p>
+<p>The “*” in the name attribute allows the mapping to match the request
URIs <code class="highlighter-rouge">/editSubscription</code>, <code class="highlighter-rouge">editRegistration</code>,

+or any other URI that starts with <code class="highlighter-rouge">/edit</code>,
however <code class="highlighter-rouge">/editSubscription/add</code> would not
be matched. The part of the URI 
+matched by the wildcard will then be substituted into various attributes of the action mapping
and its action results 
+replacing <code class="highlighter-rouge"><span class="p">{</span><span
class="err">1</span><span class="p">}</span></code>. For the rest
of the request, the framework will see the action mapping and its action results containing

+the new values.</p>
 
-<p>Mappings are matched against the request in the order they appear in the framework’s
configuration file. If more than one pattern matches <strong>the last one wins</strong>,
so less specific patterns must appear before more specific ones. However, if the request URL
can be matched against a path without any wildcards in it, no wildcard matching is performed
and order is not important. Also, note that wildcards are not greedy, meaning they only match
until the first occurrence of the following string pattern.  For example, consider the following
mapping:</p>
+<p>Mappings are matched against the request in the order they appear in the framework’s
configuration file. If more than 
+one pattern matches <strong>the last one wins</strong>, so less specific patterns
must appear before more specific ones. However, 
+if the request URL can be matched against a path without any wildcards in it, no wildcard
matching is performed 
+and order is not important. Also, note that wildcards are not greedy, meaning they only match
until the first 
+occurrence of the following string pattern.  For example, consider the following mapping:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;action name="List*s" class="actions.List{1}s"&gt;
-  &lt;result&gt;list{1}s.jsp&lt;/result&gt;
-&lt;/action&gt;
-
-</code></pre>
-</div>
-
-<p>This mapping would work correctly for the URI</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>ListAccounts
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"List*s"</span> <span
class="na">class=</span><span class="s">"actions.List{1}s"</span><span
class="nt">&gt;</span>
+  <span class="nt">&lt;result&gt;</span>list{1}s.jsp<span class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
-<p>but not</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>ListSponsors
-</code></pre>
-</div>
-<p>, because the latter would turn into this configuration:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;action name="ListSpons" class="actions.ListSpons"&gt;
-  &lt;result&gt;listSpons.jsp&lt;/result&gt;
-&lt;/action&gt;
+<p>This mapping would work correctly for the URI <code class="highlighter-rouge">ListAccounts</code>
but not <code class="highlighter-rouge">ListSponsors</code>, because the latter
would turn into 
+this configuration:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"ListSpons"</span> <span
class="na">class=</span><span class="s">"actions.ListSpons"</span><span
class="nt">&gt;</span>
+  <span class="nt">&lt;result&gt;</span>listSpons.jsp<span class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
 <p>Wildcard patterns can contain one or more of the following special tokens:</p>
 
-<p>|*|Matches zero or more characters excluding the slash (‘/’) character.|
-|–|———————————————————————|
-|**|Matches zero or more characters including the slash (‘/’) character.|
-|\character|The backslash character is used as an escape sequence. Thus \
-‘\*’ matches the character asterisk (‘*’), and \
-‘\\’ matches the character backslash (‘\’).|</p>
-
-<p>Patterns can optionally be matched “loosely”. When the end of the pattern
matches *[^*]*$ (wildcard, no wildcard, wildcard), if the pattern fails, it is also matched
as if the last two characters didn’t exist. The goal is to support the legacy “*!*”
syntax, where the “!*” is optional.</p>
-
 <table>
+  <thead>
+    <tr>
+      <th>*</th>
+      <th>Matches zero or more characters excluding the slash (‘/’) character.</th>
+    </tr>
+  </thead>
   <tbody>
     <tr>
+      <td>**</td>
+      <td>Matches zero or more characters including the slash (‘/’) character.</td>
+    </tr>
+    <tr>
+      <td>\character</td>
+      <td>The backslash character is used as an escape sequence. Thus <code class="highlighter-rouge">\\*</code>
matches the character asterisk (“*”), and <code class="highlighter-rouge">'\\'</code>
matches the character backslash (“\”).</td>
     </tr>
   </tbody>
 </table>
 
-<p>In the action mapping and action results, the wildcard-matched values can be accessed
with the token {N} where N is a number from 1 to 9 indicating which wildcard-matched value
to substitute. The whole request URI can be accessed with the {0} token.</p>
+<p>Patterns can optionally be matched “loosely”. When the end of the pattern
matches <code class="highlighter-rouge">*[^*]*$</code> (wildcard, no wildcard,

+wildcard), if the pattern fails, it is also matched as if the last two characters didn’t
exist. The goal is to support 
+the legacy <code class="highlighter-rouge">*!*</code> syntax, where the <code
class="highlighter-rouge">!*</code> is optional.</p>
+
+<p>In the action mapping and action results, the wildcard-matched values can be accessed
with the token <code class="highlighter-rouge"><span class="p">{</span><span
class="err">N</span><span class="p">}</span></code> where N is

+a number from 1 to 9 indicating which wildcard-matched value to substitute. The whole request
URI can be accessed with 
+the <code class="highlighter-rouge"><span class="p">{</span><span class="err">0</span><span
class="p">}</span></code> token.</p>
 
 <p>Also, the action mapping and action result properties will accept wildcard-matched
strings in their value attribute, like:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;action name="/edit/*" class="org.apache.struts.webapp.example.Edit{1}Action"&gt;
-    &lt;param name="id"&gt;{1}&lt;/param&gt;
-    &lt;result&gt;
-      &lt;param name="location"&gt;/mainMenu.jsp&lt;/param&gt;
-      &lt;param name="id"&gt;{1}&lt;/param&gt; 
-    &lt;/result&gt;
-&lt;/action&gt;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"/edit/*"</span> <span
class="na">class=</span><span class="s">"org.apache.struts.webapp.example.Edit{1}Action"</span><span
class="nt">&gt;</span>
+    <span class="nt">&lt;param</span> <span class="na">name=</span><span
class="s">"id"</span><span class="nt">&gt;</span>{1}<span class="nt">&lt;/param&gt;</span>
+    <span class="nt">&lt;result&gt;</span>
+      <span class="nt">&lt;param</span> <span class="na">name=</span><span
class="s">"location"</span><span class="nt">&gt;</span>/mainMenu.jsp<span
class="nt">&lt;/param&gt;</span>
+      <span class="nt">&lt;param</span> <span class="na">name=</span><span
class="s">"id"</span><span class="nt">&gt;</span>{1}<span class="nt">&lt;/param&gt;</span>

+    <span class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
-<p>(light-on) See also <a href="#PAGE_14122">Wildcard Method</a></p>
-
-<p>#####Parameters in namespaces#####</p>
+<blockquote>
+  <p>See also <a href="../getting-started/wildcard-method-selection.html">Wildcard
Method</a></p>
+</blockquote>
 
-<p>From Struts 2.1+ namespace patterns can be extracted as request parameters and bound
to the action. To enable this feature, set the following constant in struts.xml:</p>
+<h2 id="parameters-in-namespaces">Parameters in namespaces</h2>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;constant name="struts.patternMatcher" value="namedVariable"/&gt;
+<p>From Struts 2.1+ namespace patterns can be extracted as request parameters and bound
to the action. To enable this 
+feature, set the following constant in struts.xml:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;constant</span>
<span class="na">name=</span><span class="s">"struts.patternMatcher"</span>
<span class="na">value=</span><span class="s">"namedVariable"</span><span
class="nt">/&gt;</span>
 </code></pre>
 </div>
 
-<p>With that in place, namespace definitions can contain {PARAM_NAME} patterns which
will be evaluated against the request URL and extracted as parameters, for example:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>
-@Namespace{"/users/{userID}");
-public class DetailsAction exends ActionSupport {
-  private Long userID;
-  public void setUserID(Long userID) {...}
-}
+<p>With that in place, namespace definitions can contain {PARAM_NAME} patterns which
will be evaluated against the request 
+URL and extracted as parameters, for example:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nd">@Namespace</span><span
class="o">{</span><span class="s">"/users/{userID}"</span><span class="o">);</span>
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DetailsAction</span> <span class="n">exends</span> <span
class="n">ActionSupport</span> <span class="o">{</span>
+  <span class="kd">private</span> <span class="n">Long</span> <span
class="n">userID</span><span class="o">;</span>
+  <span class="kd">public</span> <span class="kt">void</span> <span
class="n">setUserID</span><span class="o">(</span><span class="n">Long</span>
<span class="n">userID</span><span class="o">)</span> <span class="o">{...}</span>
+<span class="o">}</span>
 </code></pre>
 </div>
 
-<p>If the request URL is <em>/users/10/detail</em> , then the DetailsAction
will be executed and its userID field will be set to <em>10</em> .</p>
-
-<blockquote>
-
-</blockquote>
-
-<blockquote>
-
-</blockquote>
-
-<blockquote>
-  <p>Only one PatternMatcher implementation can be used at a time.  The two implementations
included with Struts 2 are mutually exclusive.  You cannot use Wildcards and Named Variable
patterns at the same application (if that were required, you’d need to create a custom
PatternMatcher implementation).</p>
-</blockquote>
-
-<blockquote>
-
-</blockquote>
-
-<blockquote>
-
-</blockquote>
+<p>If the request URL is <code class="highlighter-rouge">/users/10/detail</code>,
then the <code class="highlighter-rouge">DetailsAction</code> will be executed
and its userID field will be set 
+to <em>10</em>.</p>
 
 <blockquote>
-  <p>Some tags tags not are 100% compatible with variables in the namespace. For instance,
they may write the literal namespace into the HTML (eg /{user}/2w) instead of the path used
in the request (ie. /brett/24).  This usually affects attributes that attempt to guess the
namespace of an action (eg. Form tag, Action tag, action=). This problem can be avoided by
using HTML tags directly with relative paths or explicit URLs.</p>
+  <p>Only one <code class="highlighter-rouge">PatternMatcher</code> implementation
can be used at a time.  The two implementations included with Struts 2 are 
+mutually exclusive.  You cannot use Wildcards and Named Variable patterns at the same application
(if that were required, 
+you’d need to create a custom PatternMatcher implementation).</p>
 </blockquote>
 
 <blockquote>
-
+  <p>Some tags tags not are 100% compatible with variables in the namespace. For instance,
they may write the literal 
+namespace into the HTML (eg.: <code class="highlighter-rouge">/{user}/2w</code>)
instead of the path used in the request (ie. <code class="highlighter-rouge">/brett/24</code>).
 This usually 
+affects attributes that attempt to guess the namespace of an action (eg. Form tag, Action
tag, action=). This problem 
+can be avoided by using HTML tags directly with relative paths or explicit URLs.</p>
 </blockquote>
 
-<table>
-  <tbody>
-    <tr>
-    </tr>
-  </tbody>
-</table>
+<p>Similar functionality can also be implemented using a custom <code class="highlighter-rouge">ActionMapper</code>.
The <code class="highlighter-rouge">ActionMapper</code> will need to parse 
+the namespace and request itself to set parameters on the matched action.  The default <code
class="highlighter-rouge">ActonMapper</code> is responsible 
+for invoking the <code class="highlighter-rouge">PatternMatcher</code>.</p>
 
-<table>
-  <tbody>
-    <tr>
-      <td>Similar functionality can also be implemented using a custom ActionMapper.
 The ActionMapper will need to parse the namespace and request itself to set parameters on
the matched action.  The default ActonMapper is responsible for invoking the PatternMatcher.</td>
-    </tr>
-  </tbody>
-</table>
-
-<table>
-  <tbody>
-    <tr>
-    </tr>
-  </tbody>
-</table>
-
-<p>#####Parameters after the action name#####</p>
+<h2 id="parameters-after-the-action-name">Parameters after the action name</h2>
 
 <p>To use parameters in the URL, after the action name, make sure this is set:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;constant name="struts.enable.SlashesInActionNames" value="true"/&gt;
-&lt;constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/&gt;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;constant</span>
<span class="na">name=</span><span class="s">"struts.enable.SlashesInActionNames"</span>
<span class="na">value=</span><span class="s">"true"</span><span
class="nt">/&gt;</span>
+<span class="nt">&lt;constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.alwaysSelectFullNamespace"</span> <span class="na">value=</span><span
class="s">"false"</span><span class="nt">/&gt;</span>
 </code></pre>
 </div>
 
 <p>Then the action mapping will look like:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;package name="edit" extends="struts-default" namespace="/edit"&gt;
-    &lt;action name="/person/*" class="org.apache.struts.webapp.example.EditAction"&gt;
-        &lt;param name="id"&gt;{1}&lt;/param&gt;
-        &lt;result&gt;/mainMenu.jsp&lt;/result&gt;
-    &lt;/action&gt;   
-&lt;/package&gt;
-
-</code></pre>
-</div>
-
-<p>When a URL like</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>/edit/person/123
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;package</span>
<span class="na">name=</span><span class="s">"edit"</span> <span
class="na">extends=</span><span class="s">"struts-default"</span> <span
class="na">namespace=</span><span class="s">"/edit"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;action</span> <span class="na">name=</span><span
class="s">"/person/*"</span> <span class="na">class=</span><span class="s">"org.apache.struts.webapp.example.EditAction"</span><span
class="nt">&gt;</span>
+        <span class="nt">&lt;param</span> <span class="na">name=</span><span
class="s">"id"</span><span class="nt">&gt;</span>{1}<span class="nt">&lt;/param&gt;</span>
+        <span class="nt">&lt;result&gt;</span>/mainMenu.jsp<span class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;/action&gt;</span>   
+<span class="nt">&lt;/package&gt;</span>
 </code></pre>
 </div>
-<p>is requested, EditAction will be called, and its “id” field will be set
to 123.</p>
 
-<p>#####Advanced Wildcards#####</p>
+<p>When a URL like <code class="highlighter-rouge">/edit/person/123</code>
is requested, <code class="highlighter-rouge">EditAction</code> will be called,
and its “id” field will be set to 123.</p>
 
-<p>From 2.1.9+ regular expressions can be defined defined in the action name. To use
this form of wild card, the following constants must be set:</p>
+<h2 id="advanced-wildcards">Advanced Wildcards</h2>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;constant name="struts.enable.SlashesInActionNames" value="true"/&gt;
-&lt;constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/&gt;
-&lt;constant name="struts.patternMatcher" value="regex" /&gt;
+<p>From 2.1.9+ regular expressions can be defined defined in the action name. To use
this form of wild card, the following 
+constants must be set:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;constant</span>
<span class="na">name=</span><span class="s">"struts.enable.SlashesInActionNames"</span>
<span class="na">value=</span><span class="s">"true"</span><span
class="nt">/&gt;</span>
+<span class="nt">&lt;constant</span> <span class="na">name=</span><span
class="s">"struts.mapper.alwaysSelectFullNamespace"</span> <span class="na">value=</span><span
class="s">"false"</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;constant</span> <span class="na">name=</span><span
class="s">"struts.patternMatcher"</span> <span class="na">value=</span><span
class="s">"regex"</span> <span class="nt">/&gt;</span>
 </code></pre>
 </div>
 
-<p>The regular expressions can be in two forms, the simplest one is {FIELD_NAME}, in
which case the field with the FIELD_NAME in the action will be populated with the matched
text, for example:</p>
+<p>The regular expressions can be in two forms, the simplest one is <code class="highlighter-rouge"><span
class="p">{</span><span class="err">FIELD_NAME</span><span class="p">}</span></code>,
in which case the field with 
+the <code class="highlighter-rouge">FIELD_NAME</code> in the action will be populated
with the matched text, for example:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;package name="books" extends="struts-default" namespace="/"&gt;
-    &lt;action name="/{type}/content/{title}" class="example.BookAction"&gt;
-	&lt;result&gt;/books/content.jsp&lt;/result&gt;
-    &lt;/action&gt;
-&lt;/package&gt;
-
-</code></pre>
-</div>
-
-<p>In this example, if the url</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>/fiction/content/Frankenstein
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;package</span>
<span class="na">name=</span><span class="s">"books"</span> <span
class="na">extends=</span><span class="s">"struts-default"</span> <span
class="na">namespace=</span><span class="s">"/"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;action</span> <span class="na">name=</span><span
class="s">"/{type}/content/{title}"</span> <span class="na">class=</span><span
class="s">"example.BookAction"</span><span class="nt">&gt;</span>
+	<span class="nt">&lt;result&gt;</span>/books/content.jsp<span class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;/action&gt;</span>
+<span class="nt">&lt;/package&gt;</span>
 </code></pre>
 </div>
-<p>is requested, BookAction’s field “type” will be set to “fiction”,
and the field “title” will be set to “Frankenstein”.</p>
 
-<p>The regular expression can also be in the form {FIELD_NAME:REGULAR_EXPRESSION}.
The regular expression is a normal Java regular expression. For example:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;package name="books" extends="struts-default" namespace="/"&gt;
-    &lt;action name="/{type}/{author:.+}/list" class="example.ListBooksAction"&gt;
-	&lt;result&gt;/books/list.jsp&lt;/result&gt;
-    &lt;/action&gt;
-&lt;/package&gt;
-
-</code></pre>
-</div>
+<p>In this example, if the url <code class="highlighter-rouge">/fiction/content/Frankenstein</code>
is requested, BookAction’s field “type” will be set to 
+“fiction”, and the field “title” will be set to “Frankenstein”.</p>
 
-<p>In this example, if the url</p>
+<p>The regular expression can also be in the form <code class="highlighter-rouge"><span
class="p">{</span><span class="err">FIELD_NAME:REGULAR_EXPRESSION</span><span
class="p">}</span></code>. The regular expression is a normal 
+Java regular expression. For example:</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>/philosophy/AynRand/list
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;package</span>
<span class="na">name=</span><span class="s">"books"</span> <span
class="na">extends=</span><span class="s">"struts-default"</span> <span
class="na">namespace=</span><span class="s">"/"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;action</span> <span class="na">name=</span><span
class="s">"/{type}/{author:.+}/list"</span> <span class="na">class=</span><span
class="s">"example.ListBooksAction"</span><span class="nt">&gt;</span>
+	<span class="nt">&lt;result&gt;</span>/books/list.jsp<span class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;/action&gt;</span>
+<span class="nt">&lt;/package&gt;</span>
 </code></pre>
 </div>
-<p>is requested, ListBooksAction’s field “type” will be set to “philosophy”
and “author” to “AynRand”.</p>
 
-<p>The matched groups can still be accessed using the {X} notation, like:</p>
+<p>In this example, if the url <code class="highlighter-rouge">/philosophy/AynRand/list</code>
is requested, ListBooksAction’s field “type” will be set to 
+“philosophy” and “author” to “AynRand”.</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;package name="books" extends="struts-default" namespace="/"&gt;
-    &lt;action name="/books/{ISBN}/content" class="example.BookAction"&gt;
-	&lt;result&gt;/books/{1}.jsp&lt;/result&gt;
-    &lt;/action&gt;
-&lt;/package&gt;
+<p>The matched groups can still be accessed using the <code class="highlighter-rouge"><span
class="p">{</span><span class="err">X</span><span class="p">}</span></code>
notation, like:</p>
 
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;package</span>
<span class="na">name=</span><span class="s">"books"</span> <span
class="na">extends=</span><span class="s">"struts-default"</span> <span
class="na">namespace=</span><span class="s">"/"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;action</span> <span class="na">name=</span><span
class="s">"/books/{ISBN}/content"</span> <span class="na">class=</span><span
class="s">"example.BookAction"</span><span class="nt">&gt;</span>
+	<span class="nt">&lt;result&gt;</span>/books/{1}.jsp<span class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;/action&gt;</span>
+<span class="nt">&lt;/package&gt;</span>
 </code></pre>
 </div>
 



Mime
View raw message