且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Security:对于未经身份验证的用户,显示错误403页面而不是登录表单页面

更新时间:2023-12-01 15:18:34

使用form-login时,默认的AuthenticationEntryPoint重定向到登录页面.

When you are using form-login the default AuthenticationEntryPoint redirects to the login page.

您可以通过注入

You can override this by injecting a custom entry point using the entry-point-ref attribute.

您可以将Http403ForbiddenEntryPoint的代码用作准则(或者,如果您想要的只是发送给客户端的响应代码,则可以直接使用该代码).

You can use the code for Http403ForbiddenEntryPoint as a guideline (or use that directly if all you want is a response code sent to the client).