...
Also, the action mapping and action result properties (set using the <set-property key="foo" value="bar"> syntax) will accept wildcard-matched strings in their value attribute, like:
Code Block | ||
---|---|---|
| ||
<action name="/edit/*" class="org.apache.struts.webapp.example.Edit{1}Action"> <param name="id">{1}</param> <result name="failure" path="/mainMenu.jsp"/> </action> |
See also Wildcard Method
Parameters in namespaces
...
Note |
---|
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. |
Parameters after the action name
To use parameters in the URL, after the action name, make sure this is set:
Code Block | ||||
---|---|---|---|---|
| ||||
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
|
Then the action mapping will look like:
Code Block | ||||
---|---|---|---|---|
| ||||
<package name="edit" extends="struts-default" namespace="/edit">
<action name="/person/*" class="org.apache.struts.webapp.example.EditAction">
<param name="id">{1}</param>
<result name="failure" path="/mainMenu.jsp"/>
</action>
</package>
|
When a URL like /edit/person/123
is requested, EditAction will be called, and its "id" field will be set to 123.