Table of Contents | ||||
---|---|---|---|---|
|
Description
Wiki Markup |
---|
{snippet:id=javadoc|javadoc=true|url=org.apache.struts2.dispatcher.mapper.ActionMapper} |
...
Possible uses of the ActionMapper include defining your own, cleaner namespaces, such as URLs like /person/1, which would be similar to a request to /getPerson.action?personID=1 using the DefaultActionMapper.
CompositeActionMapper
A composite action mapper that is capable of delegating to a series of ActionMapper if the former failed to obtained a valid ActionMapping or uri.
It is configured through struts.xml. For example, with the following entries in struts.xml
Code Block | ||||
---|---|---|---|---|
| ||||
<constant name="struts.mapper.class" value="composite" /> <constant name="struts.mapper.composite" value="struts,restful,restful2" /> |
When CompositeActionMapper#getMapping(HttpServletRequest, ConfigurationManager)
or CompositeActionMapper#getUriFromActionMapping(ActionMapping)
is invoked, CompositeActionMapper
...
would go through these ActionMappers in sequence starting from ActionMapper identified by struts.mapper.composite.1
, followed by
struts.mapper.composite.2
and finally struts.mapper.composite.3
(in this case) until either one of the ActionMapper return a valid result (not null) or it runs out of ActionMapper in which case it will just return null for both CompositeActionMapper#getMapping(HttpServletRequest, ConfigurationManager)
and
CompositeActionMapper#getUriFromActionMapping(ActionMapping)
methods.
For example with the following in struts.xml:
Code Block | ||||
---|---|---|---|---|
| ||||
<constant name="struts.mapper.class" value="composite" />
<constant name="struts.mapper.composite" value="struts,restful" />
|
CompositeActionMapper
will be configured with 2 ActionMapper, namely "struts" which is org.apache.struts2.dispatcher.mapper.DefaultActionMapper
and "restful" which is org.apache.struts2.dispatcher.mapper.
...
RestfulActionMapperRestfulActionMapper
. CompositeActionMapper
would consult each of them in order described above.
PrefixBasedActionMapper
Wiki Markup |
---|
{snippet:id=description|javadoc=true|url=org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper} |
...
Code Block |
---|
public class MyCustomActionMapper implements ActionMapper { public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { .... } public String getUriFromActionMapping(ActionMapping mapping) { .... } } |
See also: RestfulActionMapper
...