Home > Back-end >  Shiro springboot: @ RestControllerAdvice why can intercept to shiro permissions validation exception
Shiro springboot: @ RestControllerAdvice why can intercept to shiro permissions validation exception

Time:04-09

Unified exception to intercept:

@ RestControllerAdvice
Public class GlobalExceptionHandler {
Private static final Logger Logger=
LoggerFactory. GetLogger (GlobalExceptionHandler. Class);

@ ResponseStatus (HttpStatus BAD_REQUEST)
@ ExceptionHandler (value=https://bbs.csdn.net/topics/UnknownAccountException.class)
Public the Result handler (UnknownAccountException e) throws IOException {
E.p rintStackTrace System. (out);
LOGGER. The error (" a runtime exception: -- -- -- -- -- -- -- -- -- -- -- -- -- -- & gt;" E);
Return the Result. The fail (" account password error ", "401", null);
}


The controller layer:

@ GetMapping ("/userList ")
@ RequiresPermissions ("/user/userList ")
Public Result userList (int currentPage, int pageSize, String userName, String isEnable) {

System. The out. Println (123);

Return userService. IPageUser (currentPage, pageSize, userName, isEnable);
}

Question:
@ RestControllerAdvice learning, said that the method can be @ RequestMapping interception annotations inside the exception thrown, but shiro permissions should be through the filter to intercept check and throw an exception, why be intercepted?
  • Related