SpringMVC中手动转json
时间:2021-06-02 18:44:34
收藏:0
阅读:0
单独json化一个对象,压缩为null的字段
@RequestMapping("/toDoListApproval")
public void toDoListApproval(String id, HttpServletResponse response) throws Exception {
Object responseResult = xxxService.getById(id);
response.setHeader("Content-Type","application/json;charset=UTF-8");
ServletOutputStream out = response.getOutputStream();
IOUtils.write(JSON.toJSONString(responseResult).getBytes("UTF-8"),out);
out.flush();
}
评论(0)