码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-09-02 18:47:35      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:end   java   import   ram   pat   ann   ext   str   ide   

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

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

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

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

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

标签:end   java   import   ram   pat   ann   ext   str   ide   

原文地址:https://www.cnblogs.com/charlypage/p/9574461.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!