28 lines
672 B
Java
28 lines
672 B
Java
package com.newyetai.common.util;
|
|
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
/**
|
|
* @author Jerry.li
|
|
* @description 响应工具类
|
|
* @date 2020/4/16
|
|
*/
|
|
@Slf4j
|
|
public class ResponseUtils {
|
|
|
|
public static void printJson(HttpServletResponse response, Object data) {
|
|
response.setContentType("application/json;charset=utf-8");
|
|
try (PrintWriter out = response.getWriter();) {
|
|
out.print(JsonUtils.toJsonString(data));
|
|
out.flush();
|
|
} catch (IOException ex) {
|
|
log.error("------响应异常", ex);
|
|
}
|
|
}
|
|
}
|