Spring Framework CharacterEncodingFilter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework CharacterEncodingFilter class.

This code example shows how to use the following methods:
 
    @Test 
    public void chainMultiple() { 
        MockMvcBuilders 
                .webAppContextSetup(wac) 
                .addFilter(new CharacterEncodingFilter() ) 
                .defaultRequest(get("/").contextPath("/mywebapp")) 
                .build(); 
    } 
 
    @Configuration 
    @EnableWebMvc 
    static class WebConfig extends WebMvcConfigurerAdapter { 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setEncoding, setForceEncoding
		return new String[] { "/" }; 
	} 
	 
	@Override 
	protected Filter[] getServletFilters() { 
		CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter(); 
		encodingFilter.setEncoding("UTF-8"); 
		encodingFilter.setForceEncoding(true); 
 
		DelegatingFilterProxy reconnectDelegate = new DelegatingFilterProxy("apiExceptionHandler"); 
		 
		return new Filter[] { reconnectDelegate, encodingFilter, new HiddenHttpMethodFilter() }; 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:setEncoding, setForceEncoding
        return new Class<?>[] {WebMvcConfig.class}; 
    } 
 
    @Override 
    protected Filter[] getServletFilters() { 
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); 
        characterEncodingFilter.setEncoding("UTF-8"); 
        characterEncodingFilter.setForceEncoding(true); 
        return new Filter[] {characterEncodingFilter}; 
    } 
 
    @Override 
    protected void customizeRegistration(ServletRegistration.Dynamic registration) { 
        registration.setInitParameter("defaultHtmlEscape", "true"); 
        registration.setInitParameter("spring.profiles.active", "default"); 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:setEncoding, setForceEncoding
    @Autowired 
    private AppPreferences appPreferences; 
 
    @Bean 
    public CharacterEncodingFilter characterEncodingFilter() { 
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); 
        characterEncodingFilter.setEncoding(Charsets.UTF_8.name()); 
        characterEncodingFilter.setForceEncoding(true); 
        return characterEncodingFilter; 
    } 
 
    @Bean 
    public ByteArrayHttpMessageConverter byteArrayConverter() { 
        ByteArrayHttpMessageConverter converter = new ByteArrayHttpMessageConverter(); 
        converter.setSupportedMediaTypes(Lists.newArrayList(MediaType.IMAGE_JPEG, MediaType.IMAGE_PNG, MediaType.IMAGE_GIF)); 
        return converter; 
    } 
 
    @Bean 
    public MappingJackson2HttpMessageConverter mappingJacksonConverter() { 
5
CodeRank
This code example shows how to use the following methods:setEncoding
        return new String[]{"/"}; 
    } 
 
    @Override 
    protected Filter[] getServletFilters() { 
        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter(); 
        encodingFilter.setEncoding("UTF-8"); 
 
        TraceLogFilter traceLogFilter = new TraceLogFilter(); 
        return new Filter[]{encodingFilter, traceLogFilter}; 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
            throw new IllegalStateException("'ServicesDispatcher' could not be mapped to '" + SERVICES_MAPPING + "'"); 
        } 
    } 
 
    private void addEncodingFilter(ServletContext container) { 
        FilterRegistration.Dynamic fr = container.addFilter("encodingFilter", new CharacterEncodingFilter()); 
        fr.setInitParameter("encoding", "UTF-8"); 
        fr.setInitParameter("forceEncoding", "true"); 
        fr.addMappingForUrlPatterns(null, true, "/*"); 
    } 
 
    private void addLoggingFilter(ServletContext container) { 
        FilterRegistration.Dynamic fr = container.addFilter("loggingFilter", new CommonsRequestLoggingFilter()); 
        fr.addMappingForUrlPatterns(null, true, "/*"); 
    } 
 
} 
4
CodeRank
See Code Examples for Spring Framework CharacterEncodingFilter Methods: