页面上的中文无法显示
使用过滤器后
import java.io.IOException; import java.io.UnsupportedEncodingException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; @WebFilter() public class filter implements Filter { public filter() { // TODO Auto-generated constructor stub } public void destroy() { // TODO Auto-generated method stub } //ISO-8859-1//UTF-8 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub // place your code here request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); // pass the request along the filter chain chain.doFilter(request, response); } public void init(FilterConfig fConfig) throws ServletException { // TODO Auto-generated method stub } }
链接:https://pan.baidu.com/s/1-WQOQZrUmgBnW_zmduPDCg
提取码:icls