解决中文乱码,在web.xml中配置核心过滤器

方法一、手动编写中文乱码过滤器

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
chain.doFilter(request,response);
System.out.println("过滤器utf-8");
}




characterEncoding
dlr.co.util.CharacterEncodingFilter


characterEncoding
/*



方法二、使用核心过滤器



SetCharacterEncoding

org.springframework.web.filter.CharacterEncodingFilter


encoding
UTF-8


forceEncoding
true



SetCharacterEncoding
/*
REQUEST
FORWARD
INCLUDE


SetCharacterEncoding
*.jsp

你可能感兴趣的:(乱码)