注释部份为有问题的写法。
try {
//有问题的部份
//PrintWriter out = null;
//out = response.getWriter();
// String json = new ObjectMapper().writeValueAsString(map);
//out.write(json);
//out.flush();
//out.close();
outputStream = response.getOutputStream();
String json = new ObjectMapper().writeValueAsString(map);
outputStream.write(json.getBytes());
outputStream.flush();
outputStream.close();
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}