response 返回js的alert()语句,中文乱码如何解决,
步骤1:在后台加上如下代码:
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8;");
完整参考代码如下:
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8;");
PrintWriter writer=response.getWriter();
writer.write(
"<script type="text/javascript">alert('您踢出,即将跳到登录界面...');setInterval("",1000);parent.location.href='" + ctxPath
+ "/user/loginJsp.action'</script>");
writer.flush();
writer.close();