• SpringBoot 设置请求字符串格式为UTF-8


    增加一个过滤器

    package com.config;
    
    import com.jetsum.business.common.constant.CharsetConstant;
    import lombok.extern.slf4j.Slf4j;
    
    import javax.servlet.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    
    /**
     * 字符过滤器
     */
    @Slf4j
    public class CharsetFilter implements Filter {
    
        @Override
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
            HttpServletRequest request = (HttpServletRequest) servletRequest;
            HttpServletResponse response = (HttpServletResponse) servletResponse;
            request.setCharacterEncoding(CharsetConstant.UTF_8);
            response.setCharacterEncoding(CharsetConstant.UTF_8);
            filterChain.doFilter(servletRequest,servletResponse);
        }
    }
  • 相关阅读:
    纪念日给男(女)朋友的表白页面
    Vue组件的传值(非父子之间)
    express脚手架的安装和使用
    MongoDB数据库
    vuex状态
    MVVM框架的简单理解
    关于vue脚手架
    申请百度密钥
    svg
    微信小程序开发学习笔记
  • 原文地址:https://www.cnblogs.com/pxblog/p/13035285.html
Copyright © 2020-2023  润新知