Spring Boot配置文件详解
挖个坑先
http://www.cnblogs.com/itdragon/p/8686554.html
http://www.cnblogs.com/jtlgb/p/8532280.html
字符集设置
浏览器接收的数据出现乱码,例如出现???这种情况,这就需要设置字符集编码。
1. Spring Boot修改编码方法,在application.properties里面配置:
spring.http.encoding.charset=UTF-8
spring.http.encoding.force=true
spring.http.encoding.enabled=true
或者在Spring Boot 项目的application.yml里面配置:
spring:
http:
encoding:
charset: UTF-8
force: true
enabled: true
2. 在Bean中配置(启动类)
@Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setForceEncoding(true);
characterEncodingFilter.setEncoding("UTF-8");
registrationBean.setFilter(characterEncodingFilter);
return registrationBean;
}