Is there a more elegant way to use spring security

I encountered two problems when using spring security:

  1. if the login authentication callback needs to output json, it can only be output through response.getWriter (). Write ().
  2. if the business code is written in the login authentication callback, because all the processing is done in Filter, the business exception cannot be caught through the controller enhancer (@ RestControllerAdvice), and the exception handling requires additional coding.

after searching the information, I didn"t find any useful information. Do you have any other ways to achieve it?

Jul.23,2021
Menu