使用ObjectMapper对象的writeValue方法
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValue(response.getWriter(),msg);