Java Code Examples for org.springframework.web.filter.CharacterEncodingFilter#setForceEncoding()

The following examples show how to use org.springframework.web.filter.CharacterEncodingFilter#setForceEncoding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Initializer.java    From alf.io with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);

    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());

    configureSessionCookie(servletContext);
    
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    
    Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", cef);
    characterEncodingFilter.setAsyncSupported(true);
    characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");

    //force log initialization, then disable it
    XRLog.setLevel(XRLog.EXCEPTION, Level.WARNING);
    XRLog.setLoggingEnabled(false);

}
 
Example 2
Source File: DhisWebSpringTest.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Before
public void setup() throws Exception
{
    userService = _userService;
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding( "UTF-8" );
    characterEncodingFilter.setForceEncoding( true );
    mvc = MockMvcBuilders.webAppContextSetup( webApplicationContext )
        .addFilters( characterEncodingFilter, new ShallowEtagHeaderFilter(), filterChainProxy )
        .apply( documentationConfiguration( this.restDocumentation ) )
        .build();

    executeStartupRoutines();

    setUpTest();
}
 
Example 3
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    final CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example 4
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { encodingFilter };
}
 
Example 5
Source File: SpringBootInitializer.java    From alf.io with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public Filter characterEncodingFilter() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return cef;
}
 
Example 6
Source File: ServletContainerConfig.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Bean
public Filter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}
 
Example 7
Source File: AmqpConfig.java    From demo_springboot_rabbitmq with Apache License 2.0 5 votes vote down vote up
@Bean
public CharacterEncodingFilter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}
 
Example 8
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example 9
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example 10
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { encodingFilter };
}
 
Example 11
Source File: WebAppInitializer.java    From thymeleafexamples-layouts with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    DelegatingFilterProxy securityFilterChain = new DelegatingFilterProxy("springSecurityFilterChain");

    return new Filter[] {characterEncodingFilter, securityFilterChain};
}
 
Example 12
Source File: RoothubApplication.java    From Roothub with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean filterRegistrationBean() {
	FilterRegistrationBean registrationBean = new FilterRegistrationBean();
	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setForceEncoding(true);
	characterEncodingFilter.setEncoding("UTF-8");
	registrationBean.setFilter(characterEncodingFilter);
	return registrationBean;
}
 
Example 13
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();

	CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
	encodingFilter.setEncoding("UTF-8");
	encodingFilter.setForceEncoding(true);

	return new Filter[] { httpMethodFilter, encodingFilter };
}
 
Example 14
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example 15
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example 16
Source File: WebInitializer.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    return new Filter[]{new HiddenHttpMethodFilter(), cef};
}
 
Example 17
Source File: AppInitializer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
    CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
    encodingFilter.setEncoding("UTF-8");
    encodingFilter.setForceEncoding(true);

    return new Filter[] { encodingFilter };
}
 
Example 18
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
private CharacterEncodingFilter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}
 
Example 19
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
private CharacterEncodingFilter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}
 
Example 20
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
private CharacterEncodingFilter characterEncodingFilter() {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    return filter;
}