diff --git a/apps/rest-showcase/src/main/java/org/demo/rest/example/IndexController.java b/apps/rest-showcase/src/main/java/org/demo/rest/example/IndexController.java new file mode 100644 index 000000000..0e6d40355 --- /dev/null +++ b/apps/rest-showcase/src/main/java/org/demo/rest/example/IndexController.java @@ -0,0 +1,16 @@ +package org.demo.rest.example; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; + +@Results({ + @Result(name="success", type="redirectAction", params = {"actionName" , "orders"}) +}) +public class IndexController { + + @Action("/") + public String index() { + return "success"; + } +} diff --git a/apps/rest-showcase/src/main/webapp/index.jsp b/apps/rest-showcase/src/main/webapp/index.jsp deleted file mode 100644 index 7e3fc9d05..000000000 --- a/apps/rest-showcase/src/main/webapp/index.jsp +++ /dev/null @@ -1,2 +0,0 @@ - -<% response.sendRedirect("orders"); %> diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java index 00d58f557..12cc9d0b0 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java @@ -283,7 +283,7 @@ public class RestActionMapper extends DefaultActionMapper { if (id != null) { if (!"new".equals(id)) { if (mapping.getParams() == null) { - mapping.setParams(new HashMap()); + mapping.setParams(new HashMap()); } mapping.getParams().put(idParameterName, new String[]{id}); } @@ -291,10 +291,8 @@ public class RestActionMapper extends DefaultActionMapper { } mapping.setName(fullName); - 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; + return mapping; } private void handleDynamicMethodInvocation(ActionMapping mapping, String name) { diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java index 3de37d454..42d25185b 100644 --- a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java +++ b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java @@ -63,7 +63,7 @@ public class RestActionMapperTest extends TestCase { ActionMapping mapping = mapper.getMapping(req, configManager); - assertNull(mapping); + assertNotNull(mapping); } public void testGetMapping() throws Exception {