Filter拦截器通过response返回JSON

response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
PrintWriter out = response.getWriter();
JSONObject res = new JSONObject();
res.put("code", 1001);
res.put("message", "返回信息");
res.put("success", true);
out.append(res.toString());

// 引入的包

import java.io.IOException;
import java.io.PrintWriter;
import com.alibaba.fastjson.JSONObject;

// 返回

{
    "code": 1001,
    "success": true,
    "message": "用户TOKEN失效"
}
发布了80 篇原创文章 · 获赞 42 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/HelloWorldYangSong/article/details/105135630