参考文章:https://blog.csdn.net/qq_41956016/article/details/105377018
访问不到webapp下的图片,发现是被springmvc拦截了。加上这个配置就好了registry.addResourceHandler(“/upimgs/**”).addResourceLocations(“/upimgs/“);
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("spash.html");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/upimgs/**").addResourceLocations("/upimgs/");
//静态资源释放
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/","classpath:/static/**","classpath:/templates/","webapp");
}
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(new LoginHandlerIntercepetor())
// .addPathPatterns("/**")//添加拦截请求
// .excludePathPatterns("/login.html","/","/user/*","/css/**","/js/**","/img/**","/layui/**","/layui/*");//排除拦截请求
// }
}