美文网首页
Spring boot filter

Spring boot filter

作者: one_young | 来源:发表于2016-12-01 10:48 被阅读0次

    配置请求字符编码过滤器

    方法1:配置实现(recommended)

    spring.http.encoding.charset=UTF-8 # Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.

    spring.http.encoding.enabled=true # Enable http encoding support.

    spring.http.encoding.force=true # Force the encoding to the configured charset on HTTP requests and responses.

    方法2:编码实现

    @Bean

    public FilterRegistrationBean filterRegistrationBean() {

    FilterRegistrationBean registrationBean = new FilterRegistrationBean();

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();

    characterEncodingFilter.setEncoding("UTF-8");

    registrationBean.setFilter(characterEncodingFilter);

    return registrationBean;

    }

    相关文章

      网友评论

          本文标题:Spring boot filter

          本文链接:https://www.haomeiwen.com/subject/nadxmttx.html