SZH
2022-06-22 e1f869f20951152ed4f5a3c66cda3928dc4ecdf1
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
package com.gkhy.safePlatform.config.security.customzie;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
 
public abstract class JSONAuthentication {
 
    protected void writeJSON(HttpServletRequest req,
                             HttpServletResponse resp,
                             String content) throws IOException {
        // 设置编码格式
        resp.setContentType("text/json;charset=utf-8");
        // 处理跨域问题
        resp.setHeader("Access-Control-Allow-Origin", "*");
        resp.setHeader("Access-Control-Allow-Methods", "POST, GET");
 
        //输出JSON
        PrintWriter out = resp.getWriter();
        out.write(content);
        out.flush();
        out.close();
    }
 
}