ITPub博客

首页 > IT职业 > IT图书 > springboot设置静态资源不拦截的方法

springboot设置静态资源不拦截的方法

IT图书 作者:castlight 时间:2021-09-09 10:12:04 0 删除 编辑

springboot设置静态资源不拦截的方法

springboot不拦截静态资源需配置如下的类:

import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;@Configurationpublic class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {    /**
     * 配置静态访问资源
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");        super.addResourceHandlers(registry);
    }
}



作者:Dream城堡
链接:https://www.jianshu.com/p/68d9a174325b



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1470/viewspace-2818042/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: JS中的异步
请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    102
  • 访问量
    1240