zhoushihao
2024-04-18 29ea56cf0546726a83da815ee6721090311f5567
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
    }
}