在Servlet中,你的数据获取到了,但是中文是“?”,出现一个输出中文乱码的问题,把下面三行代码加上就可以了
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");//1
response.setContentType("text/html;charset=utf-8");//2
response.setCharacterEncoding("utf-8"); //3
HandleImpl xm = new HandleImpl();
List list = xm.getStudentes();
JSONArray json=JSONArray.fromObject(list);
PrintWriter out = response.getWriter();
out.println(json);
out.flush();
out.close();
}---------------------本文来自 听雨季节 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/qq_30072293/article/details/76976130?utm_source=copy