当前位置: 首页>>代码示例>>Java>>正文


Java CharacterEncodingFilter.setEncoding方法代码示例

本文整理汇总了Java中org.springframework.web.filter.CharacterEncodingFilter.setEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java CharacterEncodingFilter.setEncoding方法的具体用法?Java CharacterEncodingFilter.setEncoding怎么用?Java CharacterEncodingFilter.setEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.filter.CharacterEncodingFilter的用法示例。


在下文中一共展示了CharacterEncodingFilter.setEncoding方法的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"));
   }
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:19,代码来源:SecurityWebApplicationInitializer.java

示例2: 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();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:17,代码来源:DhisWebSpringTest.java

示例3: 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));
}
 
开发者ID:gill3s,项目名称:opentipbot,代码行数:20,代码来源:OpenTipBotApplicationConfig.java

示例4: 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);
}
 
开发者ID:osiam,项目名称:addon-administration,代码行数:18,代码来源:SecurityConfig.java

示例5: 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);

}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:22,代码来源:Initializer.java

示例6: 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);
}
 
开发者ID:qatang,项目名称:ctm,代码行数:18,代码来源:WebInitializer.java

示例7: 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));
}
 
开发者ID:the-james-burton,项目名称:sshw,代码行数:25,代码来源:RootApplicationConfig.java

示例8: 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);
	}
	
}
 
开发者ID:IHTSDO,项目名称:snomed-release-service,代码行数:22,代码来源:AbstractControllerTest.java

示例9: 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;
}
 
开发者ID:fabianogoes,项目名称:bruxelas,代码行数:9,代码来源:BruxelasApplication.java

示例10: 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};
}
 
开发者ID:brainysoon,项目名称:superhouse,代码行数:10,代码来源:SuperHouseWebAppInitializer.java

示例11: filterRegistrationBean

import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
@Bean
public FilterRegistrationBean filterRegistrationBean() {
	CharacterEncodingFilter filter = new CharacterEncodingFilter();
	filter.setEncoding("UTF-8");

	FilterRegistrationBean registrationBean = new FilterRegistrationBean();
	registrationBean.setFilter(filter);
	registrationBean.addUrlPatterns("/*");
	return registrationBean;
}
 
开发者ID:noveogroup-amorgunov,项目名称:spring-mvc-react,代码行数:11,代码来源:SpringWebConfig.java

示例12: 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));
    }
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:33,代码来源:ExampleApplicationConfig.java

示例13: 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};
}
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:12,代码来源:WebInitializer.java

示例14: 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};
}
 
开发者ID:lordking,项目名称:spring-rest-sample,代码行数:19,代码来源:AppInitializer.java

示例15: filterRegistrationBean

import org.springframework.web.filter.CharacterEncodingFilter; //导入方法依赖的package包/类
/**
 * 添加过滤器
 *
 * @return
 */
@Bean
public FilterRegistrationBean filterRegistrationBean () {
	// 过滤器注册
	FilterRegistrationBean  registrationBean = new FilterRegistrationBean();
	CharacterEncodingFilter encodingFilter   = new CharacterEncodingFilter();
	encodingFilter.setEncoding( StandardCharsets.UTF_8.displayName() );
	encodingFilter.setForceEncoding( true );
	// 字符过滤器
	registrationBean.setFilter( encodingFilter );
	// 日志处理过滤器
	registrationBean.setFilter( requestLoggingFilter() );
	return registrationBean;
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:19,代码来源:SpringConfig.java


注:本文中的org.springframework.web.filter.CharacterEncodingFilter.setEncoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。