jeecg-boot 自定义shiro返回json
在 JwtFilter 文件中
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
try {
executeLogin(request, response);
return true;
} catch (Exception e) {
// throw new AuthenticationException("Token失效,请重新登录", e);
return false;
}
}
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
httpServletResponse.setStatus(200);
httpServletResponse.setContentType("application/json;charset=utf-8");
PrintWriter out = httpServletResponse.getWriter();
out.println(JSONObject.toJSONString(Result.error(401,"token失效")));
out.flush();
out.close();
return false;
}