我已经用REST API构建了一个Spring,我正在查看HEAD请求;我如何知道它是否工作呢?
@RequestMapping(value="/employees", method= RequestMethod.GET) //used to get all employees
@RequestMapping(value="/employees", method= {RequestMethod.GET, RequestMethod.HEAD}) //same but I added the head request method在Postman中,这两种方法都会在HEAD请求中返回相同的值--那么我是否需要添加RequestMethod.HEAD呢?我怎样才能检查它是否正常工作?
谢谢!
发布于 2022-06-06 11:16:20
映射到GET的@RequestMapping方法也被隐式映射到HEAD,即不需要显式声明HEAD。HTTP HEAD请求被处理得就像它是一个HTTP GET,除了不写正文之外,只计算字节数和设置Content-Length头。
https://stackoverflow.com/questions/72516551
复制相似问题