spring boot 新增spring mvc 訊息轉化器 (五)
阿新 • • 發佈:2019-02-16
com.heimeiqiu.config.CommonConfig 訊息轉化器
package com.heimeiqiu.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.StringHttpMessageConverter; import java.nio.charset.Charset; /** * Created by wxl on 2017/12/14.* 公共配置類 */ @Configuration //開啟配置 public class CommonConfig { /** * 訊息轉化器 預設 UTF-8 * @return */ @Bean public StringHttpMessageConverter stringHttpMessageConverter() { StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8")); return converter;} }