为什么有两种方法来处理Spring中的静态资源(addResourceHandlers和容器的默认Servlet)

  @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        LOGGER.debug("configureDefaultServletHandling");
        configurer.enable();
    }

@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations( "/static/");
    }

【参考资料】

  1. Why are there 2 ways to handle static resources in Spring (addResourceHandlers and the container’s Default Servlet”)?

你可能感兴趣的:(spring)