@Configuration ... public class WebMvcAutoConfiguration { @Configuration ... public static class EnableWebMvcConfiguration{ // this.mvcProperties.getStaticPathPattern() 得到静态资源路径 @Bean public WelcomePageHandlerMapping welcomePageHandlerMapping(..., ResourceUrlProvider mvcResourceUrlProvider) { WelcomePageHandlerMapping welcomePageHandlerMapping = new WelcomePageHandlerMapping(new TemplateAvailabilityProviders(applicationContext), applicationContext, this.getWelcomePage(), this.mvcProperties.getStaticPathPattern()); welcomePageHandlerMapping.setInterceptors(this.getInterceptors(mvcConversionService, mvcResourceUrlProvider)); welcomePageHandlerMapping.setCorsConfigurations(this.getCorsConfigurations()); return welcomePageHandlerMapping; } } }
final class WelcomePageHandlerMapping { ... // 静态资源路径下的 index.html文件 WelcomePageHandlerMapping(.., Resource welcomePage, String staticPathPattern) { if (welcomePage != null && "/**".equals(staticPathPattern)) { logger.info("Adding welcome page: " + welcomePage); this.setRootViewName("forward:index.html"); } else if (this.welcomeTemplateExists(templateAvailabilityProviders, applicationContext)) { logger.info("Adding welcome page template: index"); this.setRootViewName("index"); } } }2)index.html
2、图标
在Spring Boot2.2.x中,将默认的favicon.ico移除,同时也不再提供上述application.properties中的属性配置
实现方式
把图标放在任一静态资源路径下;图标名字不要用 favicon.ico,可改为 favicon1.ico在html页面的head中加入
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)