起因
给app写了一个后台管理,最后想着加上拦截器吧省的客户不遵守游戏规则
拦截器代码
package com.example.app.comm;
import org.springframework.beans.factory.annotation.Value;
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.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${file.path}")
private String path;
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler("/img/**").addResourceLocations("file:"+path);
WebMvcConfigurer.super.addResourceHandlers(registry);
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new L