recently we moved to spring 3.0 Controller handling like this:
@Controller
public class MyController {
@RequestMapping(method = RequestMethod.POST)
pro
I believe this is what you're looking for: http://www.axelfontaine.com/2009/09/transparently-supporting-http-head.html
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
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.