修改部门问题

This commit is contained in:
2025-07-24 16:04:36 +08:00
parent 87825b2d88
commit 21a1e61c46
5 changed files with 18 additions and 12 deletions

View File

@ -25,10 +25,19 @@ public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, S
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
throws IOException
{
int code = HttpStatus.UNAUTHORIZED;
String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
try
{
response.setStatus(401);
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().print(JSON.toJSONString(AjaxResult.error(code, msg)));
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
}