We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`package com.cdn.flex.config;
import cn.dev33.satoken.interceptor.SaInterceptor; import cn.dev33.satoken.router.SaRouter; import cn.dev33.satoken.stp.StpUtil; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
蔡定努
2024/11/13 17:02 */ @configuration public class SaTokenConfigure implements WebMvcConfigurer { // 注册 Sa-Token 拦截器,打开注解式鉴权功能 @OverRide public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin())) .addPathPatterns("/**") .excludePathPatterns("/user/addMoney"); } } @RequestMapping("addMoney") public SaResult addMoney() {
if (1==1){ throw new RuntimeException("test"); } return SaResult.ok();
} `
此时应该报错RuntimeException,但是实际是NotLoginException,注解@SaCheckLogin 方式没问题
The text was updated successfully, but these errors were encountered:
底层拦截了,可以全局异常处理
@ExceptionHandler(NotPermissionException.class) public Result<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) { return Result.noAuth(); } @ExceptionHandler(NotLoginException.class) public Result<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) { return Result.noAuth(); }
Sorry, something went wrong.
No branches or pull requests
使用版本:
cn.dev33 sa-token-spring-boot-starter 1.39.0涉及的功能模块:
cn.dev33 sa-token-spring-boot-starter 1.39.0测试步骤:
`package com.cdn.flex.config;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
蔡定努
2024/11/13 17:02
*/
@configuration
public class SaTokenConfigure implements WebMvcConfigurer {
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
@OverRide
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
.addPathPatterns("/**")
.excludePathPatterns("/user/addMoney");
}
}
@RequestMapping("addMoney")
public SaResult addMoney() {
}
`
此时应该报错RuntimeException,但是实际是NotLoginException,注解@SaCheckLogin 方式没问题
The text was updated successfully, but these errors were encountered: