puhanshu
2022-07-23 bbda2ee1af4e86d76f93e00386d77efb56c60d5f
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/ResultUtil.java
New file
@@ -0,0 +1,29 @@
package com.panzhihua.common.utlis;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 返回json
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-11-24 16:03
 **/
@Slf4j
public class ResultUtil {
    public static void responseJson(HttpServletResponse httpServletResponse, Object object) {
        try {
            httpServletResponse.setContentType("application/json;charset=utf-8");
            httpServletResponse.getWriter().write(JSONObject.toJSONString(object));
        } catch (IOException e) {
            e.printStackTrace();
            log.error("返回数据到前端失败");
        }
    }
}