package com.gkhy.exam.framework.config; import com.gkhy.exam.framework.interceptor.RepeatSubmitInterceptor; import org.springframework.beans.factory.annotation.Autowired; 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; import java.io.File; @Configuration // 指定要扫描的Mapper类的包的路径 public class MyWebMvcConfig implements WebMvcConfigurer { @Value("${image.upload_image}") private String uploadPath; @Autowired private RepeatSubmitInterceptor repeatSubmitInterceptor; /** * 配置图片访问路径 * @param registry */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String systemDir=System.getProperty("user.dir"); registry.addResourceHandler("/images/**").addResourceLocations("file:"+systemDir+ File.separator+uploadPath+File.separator); } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**"); } }