| 1 | |
package com.ctrip.framework.apollo.common.controller; |
| 2 | |
|
| 3 | |
import javax.servlet.DispatcherType; |
| 4 | |
|
| 5 | |
import org.springframework.boot.context.embedded.FilterRegistrationBean; |
| 6 | |
import org.springframework.context.annotation.Bean; |
| 7 | |
import org.springframework.context.annotation.Configuration; |
| 8 | |
import org.springframework.web.filter.CharacterEncodingFilter; |
| 9 | |
|
| 10 | |
@Configuration |
| 11 | 0 | public class CharacterEncodingFilterConfiguration { |
| 12 | |
|
| 13 | |
@Bean |
| 14 | |
public FilterRegistrationBean encodingFilter() { |
| 15 | 0 | FilterRegistrationBean bean = new FilterRegistrationBean(); |
| 16 | 0 | bean.setFilter(new CharacterEncodingFilter()); |
| 17 | 0 | bean.addInitParameter("encoding", "UTF-8"); |
| 18 | |
|
| 19 | |
|
| 20 | 0 | bean.setName("encodingFilter"); |
| 21 | 0 | bean.addUrlPatterns("/*"); |
| 22 | 0 | bean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD); |
| 23 | 0 | return bean; |
| 24 | |
} |
| 25 | |
} |