Esempio n. 1
0
 @Bean
 public Filter characterEncodingFilter() {
   CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
   characterEncodingFilter.setEncoding("UTF-8");
   characterEncodingFilter.setForceEncoding(true);
   return characterEncodingFilter;
 }
Esempio n. 2
0
 @Override
 protected Filter[] getServletFilters() {
   CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
   characterEncodingFilter.setEncoding(Base.DEFAULT_CHARSET);
   characterEncodingFilter.setForceEncoding(true);
   return new Filter[] {characterEncodingFilter};
 }
 @Override
 protected Filter[] getServletFilters() {
   CharacterEncodingFilter filter = new CharacterEncodingFilter();
   filter.setEncoding("utf-8");
   filter.setForceEncoding(true);
   return new Filter[] {filter};
 }
  @Override
  protected Filter[] getServletFilters() {

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    return new Filter[] {characterEncodingFilter};
  }
Esempio n. 5
0
 @Order(Ordered.HIGHEST_PRECEDENCE)
 @Bean
 CharacterEncodingFilter characterEncodingFilter() {
   CharacterEncodingFilter filter = new CharacterEncodingFilter();
   filter.setEncoding("UTF-8");
   filter.setForceEncoding(true);
   return filter;
 }
 @Bean
 public FilterRegistrationBean filterRegistrationBean() {
   FilterRegistrationBean registrationBean = new FilterRegistrationBean();
   CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
   characterEncodingFilter.setEncoding("UTF-8");
   registrationBean.setFilter(characterEncodingFilter);
   return registrationBean;
 }
  @Override
  protected Filter[] getServletFilters() {
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    DelegatingFilterProxy securityFilterChain =
        new DelegatingFilterProxy("springSecurityFilterChain");

    return new Filter[] {characterEncodingFilter, securityFilterChain};
  }
Esempio n. 8
0
  /**
   * 中文解码
   *
   * @return
   */
  @Bean
  public FilterRegistrationBean filterRegistrationBean() {

    CharacterEncodingFilter compressingFilter = new CharacterEncodingFilter();
    compressingFilter.setEncoding("UTF-8");
    compressingFilter.setForceEncoding(true);

    FilterRegistrationBean registrationBean = new FilterRegistrationBean();

    registrationBean.setFilter(compressingFilter);

    return registrationBean;
  }
Esempio n. 9
0
  /**
   * HttpSessionEventPublisher listenert letrehozzuk, mivel kelleni fog a belepeshez, ha egyszerre
   * csak 1 user lehet 1 tokennel 1 sessionben
   */
  @Override
  protected void registerContextLoaderListener(ServletContext servletContext) {
    HttpSessionEventPublisher httpSessionEventPublisher = new HttpSessionEventPublisher();
    servletContext.addListener(httpSessionEventPublisher);

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);
    servletContext
        .addFilter("characterEncodingFilter", characterEncodingFilter)
        .addMappingForUrlPatterns(null, false, "/*");

    super.registerContextLoaderListener(servletContext);
  }
Esempio n. 10
0
  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("com.sms.config");

    // 加入logback监听器
    servletContext.addListener(new LogbackConfigListener());

    // 加入spring监听器
    servletContext.addListener(new ContextLoaderListener(context));

    EnumSet<DispatcherType> dispatcherTypes =
        EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);

    // 加入spring mvc配置
    ServletRegistration.Dynamic dispatcher =
        servletContext.addServlet("spring-mvc", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");

    // 加入OpenEntityManagerInViewFilter
    FilterRegistration.Dynamic openEntityManagerInViewFilter =
        servletContext.addFilter(
            "openEntityManagerInViewFilter", OpenEntityManagerInViewFilter.class);
    openEntityManagerInViewFilter.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    // 加入security过滤器
    FilterRegistration.Dynamic securityFilterChain =
        servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy());
    securityFilterChain.addMappingForUrlPatterns(dispatcherTypes, true, "/*");

    // 加入Spring编码过滤器
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    FilterRegistration.Dynamic encodingFilter =
        servletContext.addFilter("characterEncodingFilter", characterEncodingFilter);
    encodingFilter.addMappingForUrlPatterns(dispatcherTypes, true, "/");
  }
Esempio n. 11
0
  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    Dynamic servlet =
        servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/*");

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);
    FilterRegistration.Dynamic characterEncoding =
        servletContext.addFilter("characterEncoding", characterEncodingFilter);
    EnumSet<DispatcherType> dispatcherTypes =
        EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/");

    FilterRegistration.Dynamic corsFilter =
        servletContext.addFilter("corsFilter", CORSFilter.class);
    corsFilter.addMappingForUrlPatterns(null, false, "/*");

    super.onStartup(servletContext);
  }
 @Override
 protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
   CharacterEncodingFilter utf8filter = new CharacterEncodingFilter();
   utf8filter.setEncoding("UTF-8");
   insertFilters(servletContext, utf8filter);
 }
 @Override
 protected Filter[] getServletFilters() {
   CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
   encodingFilter.setEncoding("utf-8");
   return new Filter[] {encodingFilter};
 }
Esempio n. 14
0
 @Override
 protected Filter[] getServletFilters() {
   CharacterEncodingFilter utf8Filter = new CharacterEncodingFilter();
   utf8Filter.setEncoding("UTF-8");
   return new Filter[] {new OpenEntityManagerInViewFilter()};
 }