Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » dispatcher » mapper » [javadoc | source]
org.apache.struts2.dispatcher.mapper
public class: Restful2ActionMapper [javadoc | source]
java.lang.Object
   org.apache.struts2.dispatcher.mapper.DefaultActionMapper
      org.apache.struts2.dispatcher.mapper.Restful2ActionMapper

All Implemented Interfaces:
    ActionMapper

Improved restful action mapper that adds several ReST-style improvements to action mapping, but supports fully-customized URL's via XML. The two primary ReST enhancements are:

These two improvements allow a GET request for 'category/action/movie/Thrillers' to be mapped to the action name 'movie' with an id of 'Thrillers' with an extra parameter named 'category' with a value of 'action'. A single action mapping can then handle all CRUD operations using wildcards, e.g.

<action name="movie/*" className="app.MovieAction">
<param name="id">{0}</param>
...
</action>

This mapper supports the following parameters:

The following URL's will invoke its methods:

To simulate the HTTP methods PUT and DELETE, since they aren't supported by HTML, the HTTP parameter "__http_method" will be used.

The syntax and design for this feature was inspired by the ReST support in Ruby on Rails. See http://ryandaigle.com/articles/2006/08/01/whats-new-in-edge-rails-simply-restful-support-and-how-to-use-it

Field Summary
protected static final  Log LOG     
public static final  String HTTP_METHOD_PARAM     
Fields inherited from org.apache.struts2.dispatcher.mapper.DefaultActionMapper:
METHOD_PREFIX,  ACTION_PREFIX,  REDIRECT_PREFIX,  REDIRECT_ACTION_PREFIX,  extensions
Constructor:
 public Restful2ActionMapper() 
Method from org.apache.struts2.dispatcher.mapper.Restful2ActionMapper Summary:
getIdParameterName,   getMapping,   isDelete,   isGet,   isPost,   isPut,   setIdParameterName
Methods from org.apache.struts2.dispatcher.mapper.DefaultActionMapper:
dropExtension,   getDefaultExtension,   getMapping,   getUri,   getUriFromActionMapping,   handleSpecialParameters,   isSlashesInActionNames,   parseNameAndNamespace,   setAllowDynamicMethodCalls,   setAlwaysSelectFullNamespace,   setContainer,   setExtensions,   setSlashesInActionNames
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.dispatcher.mapper.Restful2ActionMapper Detail:
 public String getIdParameterName() 
 public ActionMapping getMapping(HttpServletRequest request,
    ConfigurationManager configManager) 
 protected boolean isDelete(HttpServletRequest request) 
 protected boolean isGet(HttpServletRequest request) 
 protected boolean isPost(HttpServletRequest request) 
 protected boolean isPut(HttpServletRequest request) 
 public  void setIdParameterName(String idParameterName)