HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request = ServletActionContext.getRequest();
response.setCharacterEncoding("GBK");
response.setContentType("text/html; charset=GBK");
PrintWriter out = response.getWriter();
String jsonString = "如果不加上面标蓝部分两行代码,就会输出乱码";
out.add(jsonString);
out.flush();
out.close();
如果不加入标蓝部分的两行代码输出会是乱码,当然是GBK还是UTF-8就要你自己去定义了!