How do I return a 403 Forbidden in Spring MVC?

后端 未结 5 968
太阳男子
太阳男子 2020-12-29 03:14

I want my controller to return the right HTTP response code when the user lacks permission to view a particular page.

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 03:51

    You can also just throw

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

    This returns a 403 in the response header.

提交回复
热议问题