大佬教程收集整理的这篇文章主要介绍了Spring 3.0 HEAD请求,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在当前的Spring(4.3.10)中,自动支持head:
https://docs.spring.io/spring/docs/current/spring-framework- reference/web.HTML#mvc-Ann-requestmapPing-head- options
最近,我们转移到spring 3.0 Controller处理如下:
@Controller
public class MyController {
@requestMapping(method = requestMethod.POST)
protected String onSubmit ( Form form,Errors errors) {
// handle POST
}
@requestMapping(method = requestMethod.GET)
protected void getForm ( Form form ) {
// handle GET
}
}
现在,由于HEAD请求,我们的日志中出现了许多异常。
org.springframework.web.httprequestMethodNotSupportedException: request method 'HEAD' not supported
at org.springframework.web.servlet.mvc.Annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:621)
at org.springframework.web.servlet.mvc.Annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:422)
at org.springframework.web.servlet.mvc.Annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
...
我想像GET requests一样支持HEAD requests,但是当然要遵循http参考:
有没有人有一个优雅的解决方案,或者甚至有一个现成的弹簧解决方案?
我在网上搜索,但没有找到任何答案。
以上是大佬教程为你收集整理的Spring 3.0 HEAD请求全部内容,希望文章能够帮你解决Spring 3.0 HEAD请求所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。