zoukankan      html  css  js  c++  java
  • SpringBoot的Web开发

    自动配置原理?

      这个场景SpringBoot帮我们配置了什么,能不能修改?能修改哪些配置,能不能拓展?

    xxxAutoConfiguration:帮我们给容器中自动配置组件
    xxxProperties:配置类来封装配置文件的内容
    

    1、SpringBoot对静态资源的映射规则 

     public void addResourceHandlers(ResourceHandlerRegistry registry) {
                if (!this.resourceProperties.isAddMappings()) {
                    logger.debug("Default resource handling disabled");
                } else {
                    Duration cachePeriod = this.resourceProperties.getCache().getPeriod();
                    CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl();
                    if (!registry.hasMappingForPattern("/webjars/**")) {
                        this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{"/webjars/**"}).addResourceLocations(new String[]{"classpath:/META-INF/resources/webjars/"}).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl));
                    }
    
                    String staticPathPattern = this.mvcProperties.getStaticPathPattern();
                    if (!registry.hasMappingForPattern(staticPathPattern)) {
                        this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{staticPathPattern}).addResourceLocations(WebMvcAutoConfiguration.getResourceLocations(this.resourceProperties.getStaticLocations())).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl));
                    }
    
                }
            }
    

      所有的/webjars/**,都去classpath

       例如:输入一个url  http://localhost:8080/abc  ,如果处理器找不到,默认访问静态资源文件夹找abc

    3)、欢迎页:静态资源文件夹下面的所有index.html页面,被/**映射;   http://localhost:8080/

    4)、所有的**/favicon.ico 都是在静态资源文件下找

    模板引擎

    模板引擎意为:写一些固定的模板页面,里面装入动态的数据,在data中封装好数据, 把模板和数据装入模板引擎,把数据解析

    
    



  • 相关阅读:
    织梦调用所有栏目一级二级三级和无限级栏目输出
    织梦添加自定义独立模型缩略图字段官方的一个BUG
    织梦搜索结果增加dede:type、dede:arclist、dede:channelartlist、dede:tag等标签支持
    织梦搜索指定多个栏目的文档
    POJ 1001
    #207 Div.2 B. Flag Day
    sublime Text 2 配置 C++ 编译环境
    1011. 复数类
    1008. 二哥买期货
    MySQL/mariadb知识点——视图管理语句
  • 原文地址:https://www.cnblogs.com/ghwq/p/12888155.html
Copyright © 2011-2022 走看看