wu
2024-06-26 c59cbfa92147058b828f78ed35b15d4ef4a7ef94
hangzhoumesParent/common/springsecurity/src/main/java/com/mes/common/utils/WebUtils.java
New file
@@ -0,0 +1,30 @@
package com.mes.common.utils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * @Author : zhoush
 * @Date: 2024/4/9 19:16
 * @Description:
 */
public class WebUtils {
    /**
     * 将字符串渲染到客户端
     *
     * @param response 渲染对象
     * @param string   待渲染的字符串
     * @return null
     */
    public static String renderString(HttpServletResponse response, String string) {
        try {
            response.setStatus(200);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().print(string);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}