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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43808-43f82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43808-43f82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?