zoukankan      html  css  js  c++  java
  • springboot 首页处理

    首页处理

    @Bean
    public WelcomePageHandlerMapping welcomePageHandlerMapping(ApplicationContext applicationContext,
                                                               FormattingConversionService mvcConversionService,
                                                               ResourceUrlProvider mvcResourceUrlProvider) {
        WelcomePageHandlerMapping welcomePageHandlerMapping = new WelcomePageHandlerMapping(
            new TemplateAvailabilityProviders(applicationContext), applicationContext, getWelcomePage(), // getWelcomePage 获得欢迎页
            this.mvcProperties.getStaticPathPattern());
        welcomePageHandlerMapping.setInterceptors(getInterceptors(mvcConversionService, mvcResourceUrlProvider));
        return welcomePageHandlerMapping;
    }

    点进去继续看

            private Resource getWelcomePage() {
                for (String location : this.resourceProperties.getStaticLocations()) {
                    Resource indexHtml = getIndexHtml(location);
                    if (indexHtml != null) {
                        return indexHtml;
                    }
                }
                ServletContext servletContext = getServletContext();
                if (servletContext != null) {
                    return getIndexHtml(new ServletContextResource(servletContext, SERVLET_LOCATION));
                }
                return null;
            }
    
            private Resource getIndexHtml(String location) {
                return getIndexHtml(this.resourceLoader.getResource(location));
            }

    静态资源文件夹下的所有 index.html 页面;被 /** 映射。

    比如我访问  http://localhost:8080/ ,就会找静态资源文件夹下的 index.html

    新建一个 index.html ,在下面的3个目录中任意一个;然后访问测试  http://localhost:8080/  看结果!

  • 相关阅读:
    hibernate---核心开发接口1(重点)
    hibernate--联合主键(了解+,掌握-)
    hibernate---table_Generator
    hibernate---ID生成策略
    hibernate 注解写在哪?
    hibernate学习笔记--可选的配置属性
    软件开发的硬约束【转载】
    (2016春) 作业7: 用户体验设计案例分析
    (2016春) 第一阶段优胜者
    (2016春) 作业6 :团队作业
  • 原文地址:https://www.cnblogs.com/WarBlog/p/15119051.html
Copyright © 2011-2022 走看看