栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【SpringBoot】8、首页及图标定制【狂神篇】

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【SpringBoot】8、首页及图标定制【狂神篇】

1、首页 1)源码分析
@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

把 index.html 放在任一静态文件路径下即可

2、图标

在Spring Boot2.2.x中,将默认的favicon.ico移除,同时也不再提供上述application.properties中的属性配置

实现方式

把图标放在任一静态资源路径下;图标名字不要用 favicon.ico,可改为 favicon1.ico在html页面的head中加入



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/709006.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号