本文整理汇总了Java中org.springframework.web.filter.CharacterEncodingFilter.setForceEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java CharacterEncodingFilter.setForceEncoding方法的具体用法?Java CharacterEncodingFilter.setForceEncoding怎么用?Java CharacterEncodingFilter.setForceEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.filter.CharacterEncodingFilter
的用法示例。
在下文中一共展示了CharacterEncodingFilter.setForceEncoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeSpringSecurityFilterChain
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
// Questo serve (anche) per consentire il file upload verso url protette:
// The first option is to ensure that the MultipartFilter is specified before the Spring Security filter.
// Specifying the MultipartFilter before the Spring Security filter means that there is no authorization
// for invoking the MultipartFilter which means anyone can place temporary files on your server.
// However, only authorized users will be able to submit a File that is processed by your application.
// In general, this is the recommended approach because the temporary file upload should have a
// negligble impact on most servers.
protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
// Per aggiungere altri filtri basta metterli in fila, in ordine di esecuzione
// insertFilters(servletContext, new YadaMultipartExceptionHandler(), new MultipartFilter());
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
// L'AuditFilter lo metto prima di tutto almeno viene eseguito prima dell'autorizzazione e riesco a capire il motivo di eventuali 403
// For some reason the characterEncodingFilter can not be after the MultipartFilter otherwise encoding in forms doesn't work (for non-multipart forms).
insertFilters(servletContext, new CheckSessionFilter(), characterEncodingFilter, new AuditFilter(), new MultipartFilter(), new DelegatingFilterProxy("yadaLocalePathVariableFilter"));
}
示例2: getServletFilters
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
protected Filter[] getServletFilters(){
// создание фильтра кодировки, который позволит работать с русскими символами
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
// создание фильтра, который добавляет поддержку HTTP методов(например,таких как PUT)
HiddenHttpMethodFilter httpMethodFilter = new HiddenHttpMethodFilter();
return new Filter[]{characterEncodingFilter, httpMethodFilter};
}
示例3: setup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@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();
}
示例4: setup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Before
public void setup() throws Exception
{
objectMapper = new ObjectMapperFactoryBean().getObject();
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding( "UTF-8" );
characterEncodingFilter.setForceEncoding( true );
mvc = MockMvcBuilders.webAppContextSetup( wac )
.addFilters( characterEncodingFilter, new ShallowEtagHeaderFilter(), filterChainProxy )
.build();
executeStartupRoutines();
setUpTest();
}
示例5: onStartup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
servletContext.addListener(new ContextLoaderListener(rootContext));
}
示例6: configure
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception { // NOSONAR the authorizeRequests() throws it and
// can't be omitted
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
http.addFilterBefore(filter, CsrfFilter.class);
http.authorizeRequests()
.accessDecisionManager(decisionManager)
.antMatchers(AdminController.CONTROLLER_PATH + "/**")
.authenticated()
.and()
.exceptionHandling()
.authenticationEntryPoint(getAuthenticationEntryPoint())
.accessDeniedHandler(exceptionHandler);
}
示例7: onStartup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@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);
}
示例8: onStartup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(null, false, "/*");
servletContext.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter()).addMappingForUrlPatterns(null, false, "/*");
DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy();
delegatingFilterProxy.setTargetFilterLifecycle(true);
servletContext.addFilter("shiroFilter", delegatingFilterProxy).addMappingForUrlPatterns(null, false, "/*");
servletContext.addServlet("kaptcha", new KaptchaServlet()).addMapping("/kaptcha");
super.onStartup(servletContext);
}
示例9: onStartup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(RootApplicationContext.class);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.setAsyncSupported(true);
dispatcher.addMapping("/");
EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
servletContext.addListener(new ContextLoaderListener(rootContext));
}
示例10: setup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilter(filter, "/*").build();
Assert.assertNotNull(mockMvc);
if (uuidGenerator instanceof PesudoUUIDGenerator) {
((PesudoUUIDGenerator)uuidGenerator).reset();
}
if ( idRestClient instanceof IdServiceRestClientOfflineDemoImpl) {
((IdServiceRestClientOfflineDemoImpl)idRestClient).reset();
}
if (s3Client instanceof TestS3Client) {
final TestS3Client testS3Client = (TestS3Client) s3Client;
testS3Client.freshBucketStore();
testS3Client.createBucket(buildBucketName);
testS3Client.createBucket(publishedBucketName);
}
}
示例11: characterEncodingFilter
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public CharacterEncodingFilter characterEncodingFilter() {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
return filter;
}
示例12: getServletFilters
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
protected Filter[] getServletFilters() {
final CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
encodingFilter.setEncoding(CHARACTER_ENCODING);
encodingFilter.setForceEncoding(true);
return new Filter[]{encodingFilter};
}
示例13: onStartup
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
//If you want to use the XML configuration, comment the following two lines out.
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationContext.class);
// rootContext.scan("com.pigdroid.social.config");
//If you want to use the XML configuration, uncomment the following lines.
//XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
//rootContext.setConfigLocation("classpath:exampleApplicationContext.xml");
ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
security.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
FilterRegistration.Dynamic sitemesh = servletContext.addFilter("sitemesh", new ConfigurableSiteMeshFilter());
sitemesh.addMappingForUrlPatterns(dispatcherTypes, true, "*.jsp");
servletContext.addListener(new ContextLoaderListener(rootContext));
}
示例14: setCharacterEncodingFilter
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
/**
* Register SetCharacterEncodingFilter to convert specical characters correctly.
*
* @return filter
*/
@Bean
public FilterRegistrationBean setCharacterEncodingFilter() {
FilterRegistrationBean registration = new FilterRegistrationBean();
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(false);
this.beanFactory.autowireBean(characterEncodingFilter);
registration.setFilter(characterEncodingFilter);
registration.addUrlPatterns("/*");
return registration;
}
示例15: getServletFilters
import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
/**
* Web服务过滤器
*
* @return
*/
@Override
protected Filter[] getServletFilters() {
//所有内容按UTF-8编码
CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
encodingFilter.setEncoding("UTF-8");
encodingFilter.setForceEncoding(true);
//跨域访问支持
Filter corsfilter = new CORSFilter();
return new Filter[]{encodingFilter, corsfilter};
}