前台无论是请求Servlet还是Action
登出json取出数据在页面上显示为乱码
需在后台程序中设置响应信息的字符集
JSONArray jsonArray=JSONArray.fromObject(userList); HttpServletResponse response=(HttpServletResponse) ActionContext.getContext().get(ServletActionContext.HTTP_RESPONSE); //必须加上,防止前端从JSON中取出的数据成乱码 response.setCharacterEncoding("UTF-8"); PrintWriter out=response.getWriter(); out.print(jsonArray.toString()); System.out.println("-----------"); System.out.println(jsonArray);