Class SaInterceptor

java.lang.Object
cn.sinozg.applet.sa.SaInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public class SaInterceptor extends Object implements org.springframework.web.servlet.HandlerInterceptor
Sa-Token 综合拦截器,提供注解鉴权和路由拦截鉴权能力
重写,保证可以拿到具体异常 由全局异常处理器去处理所有的异常
Since:
2025-03-29 14:29:50
Author:
xyb
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    是否打开注解鉴权,配置为 true 时注解鉴权才会生效,配置为 false 时,即使写了注解也不会进行鉴权
  • Constructor Summary

    Constructors
    Constructor
    Description
    创建一个 Sa-Token 综合拦截器,默认带有注解鉴权能力
  • Method Summary

    Modifier and Type
    Method
    Description
    isAnnotation(boolean isAnnotation)
    设置是否打开注解鉴权:配置为 true 时注解鉴权才会生效,配置为 false 时,即使写了注解也不会进行鉴权
    boolean
    preHandle(@NotNull jakarta.servlet.http.HttpServletRequest request, @NotNull jakarta.servlet.http.HttpServletResponse response, @NotNull Object handler)
    每次请求之前触发的方法

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor

    afterCompletion, postHandle
  • Field Details

    • isAnnotation

      public boolean isAnnotation
      是否打开注解鉴权,配置为 true 时注解鉴权才会生效,配置为 false 时,即使写了注解也不会进行鉴权
  • Constructor Details

    • SaInterceptor

      public SaInterceptor()
      创建一个 Sa-Token 综合拦截器,默认带有注解鉴权能力
  • Method Details

    • isAnnotation

      public SaInterceptor isAnnotation(boolean isAnnotation)
      设置是否打开注解鉴权:配置为 true 时注解鉴权才会生效,配置为 false 时,即使写了注解也不会进行鉴权
      Parameters:
      isAnnotation - /
      Returns:
      对象自身
    • preHandle

      public boolean preHandle(@NotNull @NotNull jakarta.servlet.http.HttpServletRequest request, @NotNull @NotNull jakarta.servlet.http.HttpServletResponse response, @NotNull @NotNull Object handler) throws Exception
      每次请求之前触发的方法
      Specified by:
      preHandle in interface org.springframework.web.servlet.HandlerInterceptor
      Throws:
      Exception