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 记录一下以防以后看不懂