boot-集成freemarker
首先加入freemarker依赖 到pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
application.properties加入配置信息
##视图解析器
##jsp 视图解析器配置
#spring.mvc.view.prefix=/
#spring.mvc.view.suffix=.jsp
##增加freemarker的视图解析器
## 首先要配置模板文件的位置
spring.freemarker.template-loader-path=classpath:/templates/page/
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.request-context-attribute=request
spring.freemarker.suffix=.ftl
##数据库的连接信息
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/1609a?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT
spring.datasource.username=root
spring.datasource.password=ghw
##mybatis简写
mybatis.type-aliases-package=com.bw.entity
在templates目录下创建个page文件夹 创建list.ftl
<html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- 使用freemrker 完成列表的展示 -->
<h6>freemrker 完成列表的展示 </h>
<table>
<tr>
<td>日程编号123</td>
<td>日程名称</td>
<td>日程日期</td>
<td>日程时间</td>
<td>
<a href="toAdd" >增加</a>
</td>
</tr>
<!-- 使用list标签 遍历list集合 -->
<#list list as rc>
<tr>
<td>${rc.sid }</td>
<td>${rc.sname }</td>
<td>${rc.riqi }</td>
<td>${rc.shijian }</td>
</tr>
</#list>
</table>
</body>
</html>
页面使用list循环
<#list list as rc>