com.opensymphony.webwork.dispatcher.mapper
Class RestfulActionMapper
java.lang.Object
com.opensymphony.webwork.dispatcher.mapper.RestfulActionMapper
- All Implemented Interfaces:
- ActionMapper
public class RestfulActionMapper
- extends Object
- implements ActionMapper
A custom action mapper using the following format:
http://HOST/ACTION_NAME/PARAM_NAME1/PARAM_VALUE1/PARAM_NAME2/PARAM_VALUE2
You can have as many parameters you'd like to use. Alternatively the URL can be shortened to the following:
http://HOST/ACTION_NAME/PARAM_VALUE1/PARAM_NAME2/PARAM_VALUE2
This is the same as:
http://HOST/ACTION_NAME/ACTION_NAME + "Id"/PARAM_VALUE1/PARAM_NAME2/PARAM_VALUE2
Suppose for example we would like to display some articles by id at using the following URL sheme:
Your action just needs a setArticleId() method, and requests such as /article/1, /article/2, etc will all map
to that URL pattern.
To invoke an action without any parameters, use:
with a slash at the back, assuming 'article' is the action name.
Note: The RestfulActionMapper is not supported if you use the (deprecated) ServletDispatcher!
Note: The RestfulActionMapper doesn't takes into account the concept of namespace, hence actions
defined for RestfulActionMapper will have to resides in WebWork 'default' namespace.
- Version:
- $Date: 2007-11-12 23:50:43 +0800 (Mon, 12 Nov 2007) $ $Id: RestfulActionMapper.java 2962 2007-11-12 15:50:43Z tm_jee $
- Author:
- Cameron Braid, Jerome Bernard, Patrick Lightbody, tmjee
Field Summary |
protected static org.apache.commons.logging.Log |
LOG
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
protected static final org.apache.commons.logging.Log LOG
RestfulActionMapper
public RestfulActionMapper()
getMapping
public ActionMapping getMapping(HttpServletRequest request)
- Attempt to return an
ActionMapping
for the supplied HttpServletRequest
.
Since RestfulActionMapper
doesn't take into
account namespace, this method will not try to recognized the namespace from HttpServletRequest
but only the action name itself and its parameters as described in the javadoc of this RestfulActionMapper
.
This method will return null, if the HttpServletRequest
contains an extension eg.
http://localhost:8080/context/someAction.action etc, because RestfulActionMapper
's
url should not contains extension.
These are such that RestfulActionMapper
could fallback to other
ActionMapper
when used in conjuection with say a
CompositeActionMapper
.
- Specified by:
getMapping
in interface ActionMapper
- Parameters:
request
-
- Returns:
- ActionMapping
getUriFromActionMapping
public String getUriFromActionMapping(ActionMapping mapping)
- Attempt to return a url, for the given
ActionMapping
passed in
as its argument.
This method wll return null if ActionMapping
contains a non-null or non-empty namespace as
RestfulActionMapper
doesn't deal with namespace.
These are such that RestfulActionMapper
could fallback to other
ActionMapper
when used in conjuection with say a
CompositeActionMapper
.
- Specified by:
getUriFromActionMapping
in interface ActionMapper
- Parameters:
mapping
-
- Returns:
- String