From e14f42f386160d9b85ebf3fd189cd8c79576fc4c Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 25 Jan 2016 08:48:24 -0500 Subject: [PATCH] Update reference for HTTP HEAD and OPTIONS support Issue: SPR-13130 --- src/asciidoc/web-mvc.adoc | 22 +++++++++++++++++++++- src/asciidoc/whats-new.adoc | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/asciidoc/web-mvc.adoc b/src/asciidoc/web-mvc.adoc index a1c83a571e..b9a2e32bfe 100644 --- a/src/asciidoc/web-mvc.adoc +++ b/src/asciidoc/web-mvc.adoc @@ -590,7 +590,7 @@ are relative to the `/appointments` path. The `get()` method has a further requests for `appointments/new` are handled by that method. The `getForDay()` method shows another usage of `@RequestMapping`: URI templates. (See -<>). +<>). A `@RequestMapping` on the class level is not required. Without it, all paths are simply absolute, and not relative. The following example from the __PetClinic__ sample @@ -1162,6 +1162,26 @@ respectively instead. They are intended specifically for that purpose. ==== +[[mvc-ann-requestmapping-head-options]] +==== HTTP HEAD and HTTP OPTIONS + +`@RequestMapping` methods mapped to "GET" are also implicitly mapped to "HEAD", +i.e. there is no need to have "HEAD" explicitly declared. An HTTP HEAD request +is processed as if it was an HTTP GET except instead of writing the body only +the number of bytes are counted and the "Content-Length" header set. + +`@RequestMapping` method have built-in support for HTTP OPTIONS. By default an +HTTP OPTIONS request is handled by setting the "Allow" response header to the +HTTP methods explicitly declared on all `@RequestMapping` methods with matching +URL patterns. When no HTTP methods are explicitly declared the "Allow" header +is set to "GET,HEAD". Therefore it's highly recommended to always explicitly +declare the HTTP method(s) an `@RequestMapping` method is meant to handle. + +Although not necessary an `@RequestMapping` method can be mapped to and handle +either HTTP HEAD or HTTP OPTIONS, or both. + + + [[mvc-ann-methods]] === Defining @RequestMapping handler methods diff --git a/src/asciidoc/whats-new.adoc b/src/asciidoc/whats-new.adoc index 079d690794..505b7f2845 100644 --- a/src/asciidoc/whats-new.adoc +++ b/src/asciidoc/whats-new.adoc @@ -661,8 +661,9 @@ Spring 4.3 also improves the caching abstraction as follows: === Web Improvements +* Built-in support for <>. * New `@RestControllerAdvice` annotation combines `@ControllerAdvice` with `@ResponseBody`. -* `@ResponseStatus` can be used on a controller type is inherited for all method. +* `@ResponseStatus` can be used on a controller type and is inherited for all method. * `AsyncRestTemplate` supports request interception. === WebSocket Messaging Improvements