gpt4 book ai didi

http - Spring 3.0 HEAD 请求

转载 作者:IT老高 更新时间:2023-10-28 13:51:46 26 4
gpt4 key购买 nike

最近我们转移到 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 请求一样支持 HEAD 请求,但当然要遵守 HTTP 引用:

The HEAD method is identical to GET except that the server MUST NOT
return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification. http://www.ietf.org/rfc/rfc2616.txt

有没有人有一个优雅的解决方案,或者甚至有开箱即用的 Spring 解决方案?

我在网上搜索,但没有找到任何答案。

最佳答案

关于http - Spring 3.0 HEAD 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3803015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com