String message = "上传图片大小不能超过1MB!";
out.println("<script>parent.callback('" + message + "')</script>");

以上代码返回给JSP页面的时候通过alert(message)显示的内容会乱码,

于是在java代码上对字符串进行编码,然后到jsp页面的时候在用js进行解码。

java代码:

message = URLEncoder.encode(message, "UTF-8");

js代码:

alert(decodeURIComponent(message));      

相关文章:

  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-06-20
猜你喜欢
  • 2021-12-15
  • 2022-02-07
  • 2022-01-10
  • 2021-09-20
  • 2021-11-13
  • 2021-06-26
相关资源
相似解决方案