2016年8月3日 | Leave a comment 问题 JSF 用commandButton 刷新页面出现乱码 解决: 汗,去掉了primeface 依赖好像就行了 页面编码都需要设置成utf8 不需要什么filter 转码 以上不行 以前的项目都正常 我用最基本的hello 发现 第一次就会出现乱码 解决用filter 设置 request.setCharacterEncoding("UTF-8"); 1 request.setCharacterEncoding("UTF-8"); /** * * @author Administrator */ @WebFilter("/*") public class CodingFilter implements Filter { private static final Logger LOG = Logger.getLogger(CodingFilter.class.getName()); @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOG.info("fdsafds"); request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); } @Override public void destroy() { } } 123456789101112131415161718192021222324252627 /** * * @author Administrator */@WebFilter("/*")public class CodingFilter implements Filter { private static final Logger LOG = Logger.getLogger(CodingFilter.class.getName()); @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOG.info("fdsafds"); request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); } @Override public void destroy() { } }