java - 如何在 Spring MVC 中返回 403 Forbidden?

标签 java spring http-status-code-403 httpforbiddenhandler

我希望我的 Controller 在用户没有查看特定页面的权限时返回正确的 HTTP 响应代码。

最佳答案

你也可以扔

org.springframework.security.access.AccessDeniedException("403 returned");

这会在响应 header 中返回 403。

关于java - 如何在 Spring MVC 中返回 403 Forbidden?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45546/

相关文章:

java - Spring Security SAML 扩展,具有跨多个 tomcat web 应用程序的“记住我”功能

基于Java的memcached客户端,优化将数据放入memcache

java - 如何将名称列表扫描到数组中?

java - if 条件中函数调用中的变量所做的更改是永久性的吗?

java - Spring Boot 电子邮件发送抛出 SocketTimeoutException : Read timed out

oauth-2.0 - Google SAML app_not_configured_for_user/相当于 prompt=select_account SAML

java - 使用 Java 等从外部更改 Indesign 文件

java - 无法通过 Spring Hibernate 获得 Liquibase 工作

java - IIS 403 禁止在 URL 中使用 %2F

php - apache+php-fpm 的随机 403 错误