printWrite 乱码

response.setCharacterEncoding("utf-8");  
  response.setContentType("text/html; charset=utf-8"); 
  PrintWriter pw = response.getWriter(); 
 pw.println("<script type='text/javascript'>");
 pw.println("alert('请重新登录!');");
 httpSession.invalidate();
 pw.println("window.parent.location.href='"+onErrorUrl+"';");
 pw.println("</script>");

 

这样是没错的  但是 先 response .getWriter() 再进 设置response的话就乱码了

你可能感兴趣的:(JavaScript,html)