– 添加WebMvcConfig,注入StpLogicJwtForSimple实体,因为satoken生成使用了策略模式,默认是32位的,注入StpLogicJwtForSimple是生成三段
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
}
@Override
public void addCorsMappings(CorsRegistry registry) {
}
}
该篇文章介绍了如何在SpringMVC项目中配置WebMvcConfig,通过Autowired注入StpLogicJwtForSimple,以支持SatokenJWT策略,特别提到由于策略模式默认生成32位,因此需要针对性地处理。
460

被折叠的 条评论
为什么被折叠?



