Spring 3.0 HEAD Requests Spring 3.0 HEAD Requests spring spring

Spring 3.0 HEAD Requests


Just add HEAD as a supported method the the request mapping:

@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD})

Update: I think you can provide a custom class that extends AnnotationMethodHandlerAdapter to be the method handler (in dispatcher-servlet.xml), and just bypass the HEAD support check there. But I'd just use the replace features of an IDE to add it.


In the current Spring (4.3.10) HEAD is automatically supported:

@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 were an HTTP GET except instead of writing the body only the number of bytes are counted and the "Content-Length" header set.

https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-ann-requestmapping-head-options