如何在Spring MVC REST for JSON中设置内容长度?
2022-09-03 06:30:19
我有一些代码:
@RequestMapping(value = "/products/get", method = RequestMethod.GET)
public @ResponseBody List<Product> getProducts(@RequestParam(required = true, value = "category_id") Long categoryId) {
// some code here
return new ArrayList<>();
}
如何配置Spring MVC(或PingJackson2HttpMessageConverter.class)以默认设置正确的标头Content-Length?因为现在我的响应标头等于 -1。content-length