13693261870
2024-07-16 8cb96c927944f28e7a64a100b046c188d9182ce6
src/main/java/com/se/simu/helper/WebHelper.java
@@ -1,5 +1,6 @@
package com.se.simu.helper;
import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.request.RequestContextHolder;
@@ -273,6 +274,19 @@
    }
    /**
     * 输出JSON至页面
     */
    public static boolean writeJson2Page(HttpServletResponse res, HttpStatus status, String str) {
        res.setStatus(status.value());
        Map<String, Object> map = new HashMap(2);
        map.put("code", status.value() >= 400 ? -1 : 0);
        map.put("msg", str);
        return writeStr2Page(res, JSON.toJSONString(map));
    }
    /**
     * 输出str至页面
     */
    public static boolean writeStr2Page(HttpServletResponse res, HttpStatus status, String str) {