From 729bc5f52e36a21b1ef0bd3db127aec16c05401b Mon Sep 17 00:00:00 2001 From: wangkang Date: Wed, 17 Jan 2018 10:12:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0StringMessageConvert=E7=9A=84?= =?UTF-8?q?UTF-8=E8=BD=AC=E6=8D=A2=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/itkk/udf/core/BaseApplication.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/udf-starter-core/src/main/java/org/itkk/udf/core/BaseApplication.java b/udf-starter-core/src/main/java/org/itkk/udf/core/BaseApplication.java index 1c9f22c..b8efe19 100644 --- a/udf-starter-core/src/main/java/org/itkk/udf/core/BaseApplication.java +++ b/udf-starter-core/src/main/java/org/itkk/udf/core/BaseApplication.java @@ -8,10 +8,17 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.retry.annotation.EnableRetry; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.client.RestTemplate; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +import java.nio.charset.Charset; +import java.util.List; /** * 描述 : 系统入口 @@ -56,4 +63,20 @@ public class BaseApplication { requestFactory.setBufferRequestBody(applicationConfig.getBufferRequestBody()); return requestFactory; } + + /** + * utf8StringHttpMessageConverter + * + * @return WebMvcConfigurer + */ + @Bean + public WebMvcConfigurer utf8StringHttpMessageConverter() { + return new WebMvcConfigurerAdapter() { + @Override + public void configureMessageConverters(List> converters) { + converters.add(new StringHttpMessageConverter(Charset.forName(applicationConfig.getEncoding()))); + super.configureMessageConverters(converters); + } + }; + } }