response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
String jsonStr = "{\"name\":\"fly\",\"type\":\"虫子\"}";
PrintWriter out = null;
try {
out = response.getWriter(); out.write(jsonStr);
} catch (IOException e) {
e.printStackTrace(); }
finally
{ if (out != null) { out.close(); }
}转载自:https://blog.csdn.net/yin_jw/article/details/44161593?utm_source=copy