【问题标题】:How to remove charset=utf-8 in a Content-Type header, generated by spring-boot如何在由 spring-boot 生成的 Content-Type 标头中删除 charset=utf-8
【发布时间】:2015-09-15 12:43:17
【问题描述】:

我正在尝试在 spring-boot 中发送一个 mp4 文件作为响应正文。我尝试使用以下方法将Content-Type 标头设置为video/mp4

  1. 一个RequestMapping注解参数:

    @RequestMapping(value = "/movie.mp4", method = RequestMethod.GET, produces = "video/mp4")
    
  2. 通过HttpHeaders手动设置header值,传回ResponseEntity

每次生成的header如下:

Content-Type:video/mp4; charset=UTF-8

如何去掉charset=UTF-8 后缀?

【问题讨论】:

  • 如何设置您喜欢的值,从而阻止 spring boot 自动附加它?

标签: spring spring-boot


【解决方案1】:

调试了一些,但我发现HttpEncodingAutoConfiguration 设置了spring.http.encoding.force=true。如果您在 application.properties 中将此设置为 false,则字符集将被忽略。

【讨论】:

  • spring.http.encoding.force=false 从标题中删除字符集
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-12
  • 2023-02-06
  • 2015-08-24
  • 2011-06-09
相关资源
最近更新 更多