Tôi có một số mã:Cách đặt độ dài nội dung trong Spring MVC REST cho JSON?
@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<>();
}
Làm thế nào tôi có thể cấu hình Spring MVC (hoặc MappingJackson2HttpMessageConverter.class) để thiết lập đúng tiêu đề Content-Length theo mặc định? Vì bây giờ tiêu đề phản hồi của tôi là content-length
bằng -1.
Bạn có thể muốn kiểm tra http://forketyfork.blogspot.com/2013/06/how-to-return-file-stream-or-classpath.html – shazin
@shazin Cảm ơn bạn. Nó không phải là một giải pháp tồi. Nó hoạt động!) – ruslanys