目录
httpmessageconverters:用来转换http请求和响应的
一、springboot的模板引擎的使用
1、配置thymleaf环境
查看springboot自动配置(https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-maven-parent-pom)
引入jar包
2、thymleaf的语法
(1)、查看thymeleaf的源码
(2)、thymeleaf测试:
(3)、thymeleaf语法使用
该文档可去thymeleaf官网下载(https://www.thymeleaf.org/documentation.html)
导入thymeleaf的名称空间(在使用theleaf的时候有语法提示)
直接获取后台数据
(4)、thymeleaf语法规则
(5)、thymeleaf语法表达式
${...}的使用
工具类的使用:
*{...}的使用
@{..}的使用
测试
二、springboot对springMvc底层实现
官方文档描述:通过controller和rescontroller获取浏览器发送过来的HTTP请求,然后返回响应信息(json数据)
查看springMvc的源码
获取视图对象reresolveviewname
组合所有的视图解析器
综上,我们可以自定义视图解析器,然后candidateviews会自动全部遍历进入数组中
在主函数中我们测试一下是否如我们上面所想
查看加载时,视图解析器来到的位置
格式化转换器:类型转换、日期转换
遍历bean工厂来添加转换器,因此我们如果要添加自己的转换器,也是和创建自定义解析器是一样的方式加入到bean工厂中
httpmessageconverters:用来转换http请求和响应的
例如:user类型-->json