我正在尝试使用 ShallowEtagHeaderFilter 在我的 springboot 中实现 ETAG:
@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
System.out.println(new ShallowEtagHeaderFilter());
return new ShallowEtagHeaderFilter();
}
当我做类似的事情时,我在标题中显示了 ETAG
curl -i -X POST localhost:8080/search/XLT
但是当我请求带有在前一个中收到的 etag 的来源时,我再也看不到它了:
curl -i -X POST localhost:8080/search/XLT -H 'If-None-Match:"MY PREVIOUS REQ ETAG MD5"
我也看不到 304 Not Modified 和任何其他响应。
我的获取方法
//USER Get REQUEST
@RequestMapping(value = "/user/{user_id}", method = RequestMethod.GET)
public @ResponseBody String getReport(
@PathVariable("user_id") String userid,
HttpServletRequest request,
HttpServletResponse response) {
//Adding request type to responseList
addResponse(true, "<HTTP-GET REQUEST>");
//Call ProcessGetRequest which will return data fetched with that key
ProcessGetRequest(userid);
return displayResponseStatus();
}
有什么我必须做的事情遗漏了吗? 任何帮助将不胜感激。
最佳答案
ShallowEtagHeaderFilter
仅应用于 GET 和 HEAD 请求,这是一种相当粗糙的受支持 ETag 方式。
根据您对 CRUD 服务的编码方式,Spring supports higher-level features for such cases使用 ResponseEntity
或 WebRequest
。
关于java - 如何在 Spring Boot 中将图像嵌入到 CRUD API 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40950005/