[英]Spring Boot Webapp: compression is not applying
不使用非@ ResponseBody注释方法。 我误解了什么吗? 可能是根本原因?
压缩应用于@ResponseBody方法:
@RequestMapping(value = "/property/{id}/pano.xml", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public String getPanoXml(@PathVariable("id") Property property) {
return assetsProvider.loadUnderlyingObject(property.getPanoXml()).getObject();
}
压缩不适用于非@ResponseBody方法:
@RequestMapping(value = "/property/{id}", method = RequestMethod.GET)
public String get(Model model, @PathVariable Long id, Locale locale) throws NoSuchRequestHandlingMethodException {
LocalizedProperty lp = repository.findProperty(id, locale.getLanguage());
// TODO: replace with custom exception
if (lp == null)
throw new NoSuchRequestHandlingMethodException("get", PropertiesController.class);
model.addAttribute(lp);
return "property/show";
}
Lib版本和配置:
Spring Boot版本:1.2.4.RELEASE
查看渲染器:Thymeleaf
应用配置:
server:
tomcat:
compression: "1024"
compressableMimeTypes: "application/json,application/xml,text/html,text/xml,text/plain"
罗马回答(在评论中提问),企业反病毒软件正在修改传入的流量,以便所有响应都被解压缩。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.