MVC中Action回发中显示的乱码问题,以前解决过乱码,但这次....请大家来帮忙看看代码,这是怎么回事?
我的Action代码
boolean flag = logindao.query(logininfo);
if(flag == true){
PrintWriter pw = response.getWriter();
pw.write( "您目前不是本站会员,欢迎您注册! ");
//此时不是本站会员
return "/admin_qian/second_HuiYuan/ZhuCeTiaoKuan.jsp ";
}else{
//是本站会员,则将登录信息放在session中,以供别的页面进行登录判断
HttpSession session = request.getSession();
session.setAttribute( "UserLogin ",LoginPassWord);
//此时为本站会员
return "/admin_qian/index1.jsp ";
在上面代码中,当转向ZhuCeTiaoKuan.jsp(注册会员页面)时,整个页面的中文显示乱码.
如果直接从主页中,直接点击注册,转向该页面时,显示的中文没有问题,请教各位兄弟,帮帮忙...
------解决方案--------------------将你的jsp页面的编码方式改为GBK
------解决方案--------------------JSP页面前面加
request.setCharacterEncoding( "gbk ");
response.setContentType( "text/html;charset=gbk ");
再在TOMCAT的配置文件里加一句 URIEncoding= "gbk "
具体位置:
<Connector
port= "8080 " maxHttpHeaderSize= "8192 "
maxThreads= "150 " minSpareThreads= "25 " maxSpareThreads= "75 "
enableLookups= "false " redirectPort= "8443 " acceptCount= "100 "
connectionTimeout= "20000 " disableUploadTimeout= "true "
URIEncoding= "gbk "/>