mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Fixed restful action mapper (switched role of put/get)
WW-1475 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@495026 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -63,8 +63,8 @@ import org.apache.commons.logging.LogFactory;
|
||||
* <li><code>GET: /movie/Thrillers => method="view", id="Thrillers"</code></li>
|
||||
* <li><code>GET: /movie/Thrillers!edit => method="edit", id="Thrillers"</code></li>
|
||||
* <li><code>GET: /movie/new => method="editNew"</code></li>
|
||||
* <li><code>POST: /movie/Thrillers => method="update"</code></li>
|
||||
* <li><code>PUT: /movie/ => method="create"</code></li>
|
||||
* <li><code>POST: /movie/Thrillers => method="create"</code></li>
|
||||
* <li><code>PUT: /movie/ => method="update"</code></li>
|
||||
* <li><code>DELETE: /movie/Thrillers => method="remove"</code></li>
|
||||
* </ul>
|
||||
* <p>
|
||||
@@ -108,9 +108,9 @@ public class Restful2ActionMapper extends DefaultActionMapper {
|
||||
// Index e.g. foo/
|
||||
if (isGet(request)) {
|
||||
mapping.setMethod("index");
|
||||
|
||||
|
||||
// Creating a new entry on POST e.g. foo/
|
||||
} else if (isPost(request)) {
|
||||
} else if (isPut(request)) {
|
||||
mapping.setMethod("create");
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Restful2ActionMapper extends DefaultActionMapper {
|
||||
mapping.setMethod("view");
|
||||
|
||||
// Updating an item e.g. foo/1
|
||||
} else if (isPut(request)) {
|
||||
} else if (isPost(request)) {
|
||||
mapping.setMethod("update");
|
||||
|
||||
// Removing an item e.g. foo/1
|
||||
@@ -174,7 +174,6 @@ public class Restful2ActionMapper extends DefaultActionMapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -88,12 +88,12 @@ public class Restful2ActionMapperTest extends StrutsTestCase {
|
||||
assertEquals("1", mapping.getParams().get("bar"));
|
||||
}
|
||||
|
||||
public void testPostCreate() throws Exception {
|
||||
public void testPutCreate() throws Exception {
|
||||
req.setupGetRequestURI("/my/namespace/foo/");
|
||||
req.setupGetServletPath("/my/namespace/foo/");
|
||||
req.setupGetAttribute(null);
|
||||
req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
|
||||
req.setupGetMethod("POST");
|
||||
req.setupGetMethod("PUT");
|
||||
|
||||
ActionMapping mapping = mapper.getMapping(req, configManager);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user