Spring Boot Webapp:压缩不适用

时间:2015-07-22 12:09:23

标签: java spring spring-mvc spring-boot

不使用非@ 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();
}

gzipped

压缩不适用于非@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";
}

not gzipped

Lib版本和配置:

Spring Boot版本:1.2.4.RELEASE
查看渲染器:Thymeleaf

App config:

server:
  tomcat:
    compression: "1024"
    compressableMimeTypes: "application/json,application/xml,text/html,text/xml,text/plain"

1 个答案:

答案 0 :(得分:0)

正如罗马回答的那样(在评论中),公司的反病毒软件正在修改传入流量,以便所有响应都被解压缩。