From f56a1a025ea7305a71ce0d19e4bc24855720cfbc Mon Sep 17 00:00:00 2001 From: tanghc Date: Wed, 14 Aug 2019 14:14:12 +0800 Subject: [PATCH] 1.15.0 --- .../configuration/BaseServiceConfiguration.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java index d2a5f254..70870e83 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java @@ -48,18 +48,14 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport super.addInterceptors(registry); } - /*@Override - protected void configureMessageConverters(List> converters) { - converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8)); - }*/ - @Override protected void extendMessageConverters(List> converters) { // 解决controller返回字符串中文乱码问题 - // 移除老的 - //converters.removeIf(converter -> converter instanceof StringHttpMessageConverter); - // 添加信息的 - converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8)); + for (HttpMessageConverter converter : converters) { + if (converter instanceof StringHttpMessageConverter) { + ((StringHttpMessageConverter)converter).setDefaultCharset(StandardCharsets.UTF_8); + } + } } /**