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

The following examples show how to use org.springframework.web.filter.CharacterEncodingFilter#setEncoding() . 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: AbstractWebApplicationInitializer.java    From bearchoke with Apache License 2.0 5 votes vote down vote up
protected void createFilters(ServletContext ctx) {
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");

        SimpleCORSFilter corsFilter = new SimpleCORSFilter();
        corsFilter.setCorsAllowCredentials("true");
        corsFilter.setCorsAllowMethods("GET, POST, PUT, PATCH, DELETE, OPTIONS");
        corsFilter.setCorsAllowHeaders("content-type, x-requested-with, origin, accept, authorization, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsExposeHeaders("content-type, cookie, x-requested-with, origin, accept, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsMaxAge("3600");

        ctx.addFilter("springSessionRepositoryFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("simpleCORSFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
//        ctx.addFilter("SimpleCorsFilter", corsFilter).addMappingForUrlPatterns(
//                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("JsonHttpRequestFilter", new JsonHttpRequestFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/api/authenticate");
        ctx.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("CharacterEncodingFilter", characterEncodingFilter).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HiddenHttpMethodFilter", new HiddenHttpMethodFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HttpPutFormContentFilter", new HttpPutFormContentFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("ShallowEtagHeaderFilter", new ShallowEtagHeaderFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);

    }
 
Example 2
Source File: WebContentServiceWebApplicationInitializer.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");

    return new Filter[]{characterEncodingFilter};
}
 
Example 3
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 4
Source File: SpringWebConfig.java    From spring-mvc-react with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean filterRegistrationBean() {
	CharacterEncodingFilter filter = new CharacterEncodingFilter();
	filter.setEncoding("UTF-8");

	FilterRegistrationBean registrationBean = new FilterRegistrationBean();
	registrationBean.setFilter(filter);
	registrationBean.addUrlPatterns("/*");
	return registrationBean;
}
 
Example 5
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 6
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 7
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 8
Source File: SpringWebConfig.java    From spring-mvc-react with MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean filterRegistrationBean() {
	CharacterEncodingFilter filter = new CharacterEncodingFilter();
	filter.setEncoding("UTF-8");

	FilterRegistrationBean registrationBean = new FilterRegistrationBean();
	registrationBean.setFilter(filter);
	registrationBean.addUrlPatterns("/*");
	return registrationBean;
}
 
Example 9
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 10
Source File: Initializer.java    From SA47 with The Unlicense 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {

	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setEncoding("UTF-8");
	return new Filter[] { characterEncodingFilter, new SiteMeshFilter() };
}
 
Example 11
Source File: Initializer.java    From SA47 with The Unlicense 5 votes vote down vote up
@Override
protected Filter[] getServletFilters() {

	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setEncoding("UTF-8");
	return new Filter[] { characterEncodingFilter, new SiteMeshFilter() };
}
 
Example 12
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 13
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 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: 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 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: AppInitializer.java    From playground with Apache License 2.0 4 votes vote down vote up
@Override
protected Filter[] getServletFilters() {
	CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
	characterEncodingFilter.setEncoding("UTF-8");
	return new Filter[]{ characterEncodingFilter, new SiteMeshFilter() };
}