【问题标题】:What's mean "enabled: ture force: true" properties in this code?这段代码中的“启用:真力:真”属性是什么意思?
【发布时间】:2021-04-05 18:23:52
【问题描述】:
  http: 
    encoding:   
      charset: UTF-8
      enabled: true
      force: true

这段代码中的“enabled: ture force: true”属性是什么意思?

【问题讨论】:

  • 这看起来像是一个 yaml 配置文件。你需要给它一些上下文!
  • 对不起,这是上下文。我只想使用 yml 文件创建 Board。 spring: mvc: static-path-pattern: /resources/** view: 前缀: /WEB-INF/views/ 后缀: .jsp http: encoding: charset: UTF-8 enabled: true force: true messages: basename: message编码:UTF-8

标签: spring encoding yaml


【解决方案1】:

spring.http.encoding 在新的 Spring Boot 版本 (>2.3) 中已被弃用。所以新的 application.setting 应该是这样的:

server:
  servlet:
    encoding:
      enabled: true
      charset: UTF-8
      force: true

server.servlet.encoding.charset=UTF-8 # HTTP 请求和响应的字符集。如果未明确设置,则添加到“Content-Type”标头中。

server.servlet.encoding.enabled=true # 是否开启http编码支持。

server.servlet.encoding.force=true # 强制编码为 HTTP 请求和响应配置的字符集。

参考:Appendix Application Properties

【讨论】:

  • 谢谢!您的回复很有帮助!
猜你喜欢
  • 1970-01-01
  • 2016-03-28
  • 1970-01-01
  • 2018-01-23
相关资源
最近更新 更多