當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。