DefaultActionMapper
By default, the DefaultActionMapper is used:
In Struts 2.1.6 and earlier the Redirect Action prefix is "redirect-action", it was changed to "redirectAction" after the release of Struts 2.1.6
Method prefix
Action prefix
Redirect prefix
Redirect-action prefix
In Struts 2.1.6 and earlier the Redirect Action prefix is "redirect-action", it was changed to "redirectAction" after the release of Struts 2.1.6
Custom ActionMapper
You can define your own ActionMapper by implementing org.apache.struts2.dispatcher.mapper.ActionMapper
then configuring Struts 2 to use the new class in struts.xml
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="mymapper" class="com.mycompany.myapp.MyActionMapper" /> <constant name="struts.mapper.class" value="mymapper" />
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
PrefixBasedActionMapper
ActionMapper and ActionMapping objets
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 struts.mapper.class
entry in struts.properties
or struts.xml
. Note that the value of this constant is the name of the bean of the new mapper.
Customize
Custom ActionMapper must implement ActionMapper interface and have a default constructor.
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="mymapper" class="com.mycompany.myapp.MyActionMapper" /> <constant name="struts.mapper.class" value="mymapper" />
public class MyCustomActionMapper implements ActionMapper { public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { .... } public String getUriFromActionMapping(ActionMapping mapping) { .... } }
See also: RestfulActionMapper