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);
    }
}

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2021-09-12
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2022-01-31
  • 2021-06-03
  • 2021-06-05
  • 2021-08-01
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案