init
This commit is contained in:
27
src/main/java/com/newyetai/common/util/ResponseUtils.java
Normal file
27
src/main/java/com/newyetai/common/util/ResponseUtils.java
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user