spring boot Model 映射传值的方式
在spring boot肯定会遇到需要默认值的时候,那么如何获取到默认值呢???
其中一种方式就是在控制器映射的时候通过model传值
要用到model的话首先需要添加依赖:
<!--添加static和templates的依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
添加好templates依赖后需要更改.yml文件
找到文件夹中的这个文件,有的是有一个小叶子的图标,找到后打开文件加入以下代码,
thymeleaf