Sa-token: error on line 1 at column 48: Extra content at the end of the document

This page contains the following errors:: error on line 1 at column 48: Extra content at the end of the document


今天在尝试开源登录项目 Sa-token 时,按照官方文档要求引入Sa-Token-Quick-Login 快速登录认证登录页时,项目报错,如下:This page contains the following errors: error on line 1 at column 48: Extra content at the end of the document
在互联网上查询了许久都没有问题的产生原因与解决方法,遂写下此篇文章。


问题产生原因

  在引入 Sa-Token-Quick-Login 后,Sa-token 自身的路由拦截规则会发生改变,如果你之前私自在项目中配置过路由拦截 SaRouter,那么很有可能会产生冲突,于是项目报错。如下图:

@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 拦截器,定义详细认证规则
        registry.addInterceptor(new SaInterceptor(handler -> {
        			// 路由拦截规则
                    SaRouter.match("/**")
                            .notMatch("/user/doLogin", "/","/index")
                            .check(r -> StpUtil.checkLogin());
                })
        ).addPathPatterns("/**");
    }
}

解决方法

注释掉原先代码中编写的路由拦截规则SaRouter即可。

@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 拦截器,定义详细认证规则
        registry.addInterceptor(new SaInterceptor(handler -> {
//                    SaRouter.match("/**")
//                            .notMatch("/user/doLogin", "/","/index")
//                            .check(r -> StpUtil.checkLogin());
                })
        ).addPathPatterns("/**");
    }
}

项目成功运行
Sa-token登录页

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ThinkStu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值