diff --git a/spring-framework-reference/src/rest.xml b/spring-framework-reference/src/rest.xml index 1244979da6..4cb2eb6067 100644 --- a/spring-framework-reference/src/rest.xml +++ b/spring-framework-reference/src/rest.xml @@ -38,50 +38,6 @@ configuration to understand the general programming model. -
- HTTP Method Conversion - - A key principle of REST is the use of the Uniform Interface. This - means that all resources (URLs) can be manipulated using the same four - HTTP methods: GET, PUT, POST, and DELETE. For each methods, the HTTP - specification defines the exact semantics. For instance, a GET should - always be a safe operation, meaning that is has no side effects, and a - PUT or DELETE should be idempotent, meaning that you can repeat these - operations over and over again, but the end result should be the same. - While HTTP defines these four methods, HTML only supports two: GET and - POST. Fortunately, there are two possible workarounds: you can either - use JavaScript to do your PUT or DELETE, or simply do a POST with the - 'real' method as an additional parameter (modeled as a hidden input - field in an HTML form). This latter trick is what Spring's - HiddenHttpMethodFilter does. This filter is a - plain Servlet Filter and therefore it can be used in combination with - any web framework (not just Spring MVC). Simply add this filter to your - web.xml, and a POST with a hidden _method parameter will be converted - into the corresponding HTTP method request. - -
- Supporting Spring form tags - - To support HTTP method conversion the Spring MVC form tag was - updated to support setting the HTTP method. For example, the following - snippet taken from the updated Petclinic sample - - <form:form method="delete"> - <p class="submit"><input type="submit" value="Delete Pet"/></p> -</form:form> - - This will actually perform an HTTP POST, with the 'real' DELETE - method hidden behind a request parameter, to be picked up by the - HiddenHttpMethodFilter. The corresponding - @Controller method is shown below - - @RequestMapping(method = RequestMethod.DELETE) -public String deletePet(@PathVariable int ownerId, @PathVariable int petId) { - this.clinic.deletePet(petId); - return "redirect:/owners/" + ownerId; -} -
-
ETag support diff --git a/spring-framework-reference/src/view.xml b/spring-framework-reference/src/view.xml index 3e462f1226..25ccf2ea9e 100644 --- a/spring-framework-reference/src/view.xml +++ b/spring-framework-reference/src/view.xml @@ -737,6 +737,57 @@ productList.url=/WEB-INF/jsp/productlist.jsp </tr> </form>
+ +
+ HTTP Method Conversion + + A key principle of REST is the use of the Uniform Interface. + This means that all resources (URLs) can be manipulated using the same + four HTTP methods: GET, PUT, POST, and DELETE. For each methods, the + HTTP specification defines the exact semantics. For instance, a GET + should always be a safe operation, meaning that is has no side + effects, and a PUT or DELETE should be idempotent, meaning that you + can repeat these operations over and over again, but the end result + should be the same. While HTTP defines these four methods, HTML only + supports two: GET and POST. Fortunately, there are two possible + workarounds: you can either use JavaScript to do your PUT or DELETE, + or simply do a POST with the 'real' method as an additional parameter + (modeled as a hidden input field in an HTML form). This latter trick + is what Spring's HiddenHttpMethodFilter does. + This filter is a plain Servlet Filter and therefore it can be used in + combination with any web framework (not just Spring MVC). Simply add + this filter to your web.xml, and a POST with a hidden _method + parameter will be converted into the corresponding HTTP method + request. + + To support HTTP method conversion the Spring MVC form tag was + updated to support setting the HTTP method. For example, the following + snippet taken from the updated Petclinic sample + + <form:form method="delete"> + <p class="submit"><input type="submit" value="Delete Pet"/></p> +</form:form> + + This will actually perform an HTTP POST, with the 'real' DELETE + method hidden behind a request parameter, to be picked up by the + HiddenHttpMethodFilter, as defined in web.xml: + <filter> + <filter-name>httpMethodFilter</filter-name> + <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> +</filter> + +<filter-mapping> + <filter-name>httpMethodFilter</filter-name> + <servlet-name>petclinic</servlet-name> +</filter-mapping>The corresponding @Controller method + is shown below: + + @RequestMapping(method = RequestMethod.DELETE) +public String deletePet(@PathVariable int ownerId, @PathVariable int petId) { + this.clinic.deletePet(petId); + return "redirect:/owners/" + ownerId; +} +
@@ -2435,7 +2486,7 @@ simpleReport.reportDataKey=myBeanData -
+
Feed Views Both AbstractAtomFeedView and