Web开发使用SpringBoot

一、xxxxAutoConfiguration:帮我们给容器中自动配置组件;

xxxxProperties:配置类来封装配置文件的内容;

1.所有 /webjars/** ,都去 classpath:/META-INF/resources/webjars/ 找资源

  webjars:以jar包的方式引入静态资源;
  http://www.webjars.org/

  输入路径即可访问

2."/**" 访问当前项目的任何资源,都去(静态资源的文件夹)找映射

   localhost:8080/abc === 去静态资源文件夹里面找abc

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

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

二、模板引擎

      JSP、Velocity、Freemarker、Thymeleaf’

SpringBoot推荐的Thymeleaf;

语法更简单,功能更强大;

1.引入thymeleaf

       <dependency>        
          <groupId>org.springframework.boot</groupId>            
            <artifactId>spring‐boot‐starter‐thymeleaf</artifactId>            
           2.1.6  
        </dependency>        
        切换thymeleaf版本
         <properties>
          <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>        
             <!‐‐ 布局功能的支持程序  thymeleaf3主程序  layout2以上版本 ‐‐>        
               <!‐‐ thymeleaf2   layout1‐‐>        
             <thymeleaf‐layout‐dialect.version>2.2.2</thymeleaf‐layout‐dialect.version>        

        </properties>

2、Thymeleaf使用

    只要我们把HTML页面放在classpath:/templates/,thymeleaf就能自动渲染;1使用:

   1)导入thymeleaf的名称空间

   2)使用thymeleaf语法:

   th:text;改变当前元素里面的文本内容;
   th:任意html属性;来替换原生属性的值


猜你喜欢

转载自blog.csdn.net/qq_41978691/article/details/80092466