mirror of https://gitee.com/stylefeng/roses
【rule】增加一个渲染方法
parent
ef85da98d2
commit
25f5d010da
|
@ -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信息
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue