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); } }
-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------
(蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)