你虽然统一成UTF-8,但是注意是每个环节,结扎!
public class CharsetFilter implements Filter{
private FilterConfig config = null;
private String defaultEncode = "UTF-8";
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void destroy() {
this.config = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
System.out.println("into filter");
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// response.setCharacterEncoding("gbk");
chain.doFilter(request,response);
}
}
jsp 页面都是UTF-8编码的,eclipse的项目编码也是UTF-8 的,谢谢
当然会不一样
修改一下过滤器的配置就好了
如果后来经过数据库保存,再取出来是乱码,就表明数据库连接,没有设置乱码。
是指用System.out.println或log4j在jboss的日志文件里打印出来.
页面跳转时注意
不要onclick=goPerson(){
url = "actions/queryAction.do?modelFlag=per_all_people
&¶meterValue=<%=personName%>";
location.href=url;
}
这种形式,用document.form.submit();来提交传递。