WW-3857 changes RestActionMapper to return null if it cannot determine action mapping, adds comment to API

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1367870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2012-08-01 07:11:09 +00:00
parent 828f08ee3a
commit ec070ff937
3 changed files with 15 additions and 5 deletions
@@ -21,10 +21,10 @@
package org.apache.struts2.dispatcher.mapper;
import javax.servlet.http.HttpServletRequest;
import com.opensymphony.xwork2.config.ConfigurationManager;
import javax.servlet.http.HttpServletRequest;
/**
* <!-- START SNIPPET: javadoc -->
*
@@ -51,7 +51,7 @@ public interface ActionMapper {
*
* @param request The servlet request
* @param configManager The current configuration manager
* @return The appropriate action mapping
* @return The appropriate action mapping or null if mapping cannot be determined
*/
ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager);
@@ -289,9 +289,10 @@ public class RestActionMapper extends DefaultActionMapper {
}
mapping.setName(fullName);
return mapping;
}
return mapping;
// if action name isn't specified, it can be a normal request, to static resource, return null to allow handle that case
return null;
}
private void handleDynamicMethodInvocation(ActionMapping mapping, String name) {
@@ -57,6 +57,15 @@ public class RestActionMapperTest extends TestCase {
};
}
public void testRootMapping() throws Exception {
req.setRequestURI("/myapp/");
req.setServletPath("/");
ActionMapping mapping = mapper.getMapping(req, configManager);
assertNull(mapping);
}
public void testGetMapping() throws Exception {
req.setRequestURI("/myapp/animals/dog");
req.setServletPath("/animals/dog");