springboot配置拦截器,不起作用

本文档描述了在IDEA中创建的SpringBoot Web项目中,配置的拦截器无法正常工作的问题。当启动应用时,虽然`addInterceptors(InterceptorRegistry registry)`配置方法被调用,但拦截器的逻辑并未执行。在尝试访问URL时,拦截效果未显现。作者急需解决方案。
摘要由CSDN通过智能技术生成

刚在IDEA创建了一个springboot 的web项目 ,按网上配置拦截器没有效果!!!


启动springboot:run的时候加载了一次 addInterceptors(InterceptorRegistry registry)这个配置方法,但是没有进去拦截方法

访问url的时候,就没有拦截效果!!!急,求解



代码 1:

package com.example.springbootdemo;

import com.example.springbootdemo.Interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 配置继承WebMvcConfigurerAdapter
 * @author sam
 * @since 2017/7/16
 */

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值