【rule】增加一个渲染方法

pull/3/head
fengshuonan 2021-01-02 22:18:04 +08:00
parent ef85da98d2
commit 25f5d010da
1 changed files with 17 additions and 0 deletions

View File

@ -18,6 +18,23 @@ import java.io.IOException;
@Slf4j
public class ResponseRenderUtil {
/**
* json
*
* @author fengshuonan
* @date 2020/12/15 21:40
*/
public static void renderJsonResponse(HttpServletResponse response, Object responseData) {
response.setCharacterEncoding(CharsetUtil.UTF_8);
response.setContentType(ContentType.JSON.toString());
String errorResponseJsonData = JSON.toJSONString(responseData);
try {
response.getWriter().write(errorResponseJsonData);
} catch (IOException e) {
log.error("渲染http json信息错误", e);
}
}
/**
* json
*