ssh 控制层返回json数据方法

public void writeJson(Object object) {
try {
String json = JSON.toJSONStringWithDateFormat(object, "yyyy-MM-dd HH:mm:ss");
ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
ServletActionContext.getResponse().getWriter().write(json);
ServletActionContext.getResponse().getWriter().flush();
ServletActionContext.getResponse().getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}
posted @ 2019-05-10 16:46  久违的黎明  阅读(582)  评论(0编辑  收藏  举报