JSON 乱码问题:
处理json乱码的
一、JAVA代码中这么处理: 就是在后台上在response.getWriter()之前通过setContentType 或者 setCharacterEncoding先设定好编码
HttpServletResponse response = getResponse();
response.setContentType("text/json; charset=GBK");
response.setCharacterEncoding("GBK");
PrintWriter out = response.getWriter();
二、JSP页面头部加上:
<%@ page contentType="text/html; charset=gbk" %>
本文介绍了如何在Java和JSP环境中解决JSON文件的乱码问题。对于Java,可以通过设置response的ContentType和CharacterEncoding来指定字符集为GBK。而在JSP中,则可以在页面头部设置contentType属性。
1361

被折叠的 条评论
为什么被折叠?



