加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spring Boot Webapp:压缩不适用

发布时间:2020-12-15 02:08:07 所属栏目:Java 来源:网络整理
导读:不使用非@ ResponseBody注释方法.我误解了什么吗?可能是根本原因? 压缩应用于@ResponseBody方法: @RequestMapping(value = "/property/{id}/pano.xml",method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE)@ResponseBodypublic Strin
不使用非@ 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

应用配置:

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

解决方法

罗马回答(在评论中提问),企业反病毒软件正在修改传入的流量,以便所有响应都被解压缩.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读