参考文章:https://blog.csdn.net/qq_41956016/article/details/105377018
    image.png
    访问不到webapp下的图片,发现是被springmvc拦截了。加上这个配置就好了registry.addResourceHandler(“/upimgs/**”).addResourceLocations(“/upimgs/“);
    image.png

    1. @Configuration
    2. public class MyMvcConfig implements WebMvcConfigurer {
    3. @Override
    4. public void addViewControllers(ViewControllerRegistry registry) {
    5. registry.addViewController("/").setViewName("spash.html");
    6. }
    7. @Override
    8. public void addResourceHandlers(ResourceHandlerRegistry registry) {
    9. registry.addResourceHandler("/upimgs/**").addResourceLocations("/upimgs/");
    10. //静态资源释放
    11. registry.addResourceHandler("/**")
    12. .addResourceLocations("classpath:/static/","classpath:/static/**","classpath:/templates/","webapp");
    13. }
    14. // @Override
    15. // public void addInterceptors(InterceptorRegistry registry) {
    16. // registry.addInterceptor(new LoginHandlerIntercepetor())
    17. // .addPathPatterns("/**")//添加拦截请求
    18. // .excludePathPatterns("/login.html","/","/user/*","/css/**","/js/**","/img/**","/layui/**","/layui/*");//排除拦截请求
    19. // }
    20. }