使用流返回数据(writer)

Map<String,Object> resultMap = new HashMap<String, Object>();
resultMap.put("localcode",1);
resultMap.put("sessionId",22);
String json =(new JSONObject(resultMap)).toString();
PrintWriter writer = null;
try {
    writer = response.getWriter();
} catch (IOException e) {
    e.printStackTrace();
}
writer.write(json);
writer.flush();
writer.close();

相当于return json   记录一下以防以后看不懂

猜你喜欢

转载自blog.csdn.net/qq_36178165/article/details/86596011