简单使用:SpringBoot使用freemarker
使用步骤:
a : 添加依赖
b: 创建模板文件 保存位置resources/templates 目录下 文件后缀名.ftl
c 编写controller 把结果传递给模板
在resources.templates下创建user.ftl文件,内容如下
<html>
<head>
<title>springboot</title>
</head>
<body>
<table border="1px">
<thead>
<tr>
<th>id</th>
<th>用户名</th>
<th>密码</th>
<th>姓名</th>
</tr>
</thead>
<tbody>
<#list users as user>
<tr>
<td>${user.id}</td>
<td>${user.username}</td>
<td>${user.password}</td>
<td>${user.name}</td>
</tr>
</#list>
</tbody>
</table>
</body>
</html> dao层:
List<User> getAllUser(); Controller层:
@RequestMapping("/list")
public String show(Model mode){
List<User> users = userDao.findAll();
mode.addAttribute("users",users);
return "user";
}
简单使用:SpringBoot使用freemarker的更多相关文章
- 基于springboot的freemarker创建指定格式的word文档
在web或其他应用中,经常我们需要导出或者预览word文档,比较实际的例子有招聘网站上预览或者导出个人简历,使用POI导出excel会非常的方便,但是如果想导出word,由于其格式控制非常复杂,故而使 ...
- SpringBoot整合freemarker 引用基础
原 ElasticSearch学习笔记Ⅲ - SpringBoot整合ES 新建一个SpringBoot项目.添加es的maven坐标如下: <dependency> <groupI ...
- springboot整合freemarker
前后端分离现在越来越多,如何有效的使用springboot来整合我们的页面是一个很重要的问题. springboot整合freemarker有以下几个步骤,也总结下我所犯的错误: 1.加依赖: 2.配 ...
- springboot使用Freemarker继承
最近需要用到Freemarker的继承.但是发现没有关于springboot配置Freemarker的继承的.所以趁现在有时间写个博客. 1. Freemarker继承介绍 Freemarker 通过 ...
- 记springboot+mybatis+freemarker+bootstrap的使用(1)
一..springboot的配置 1.安装并配置maven maven是项目管理工具,可以自动下载并管理jar包之间的依赖关系,可通过maven自动配置springboot 参照百度经验https:/ ...
- SpringBoot学习8:springboot整合freemarker
1.创建maven项目,添加pom依赖 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springframewor ...
- springboot整合freemarker(转)
添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...
- 一个最简单的springboot
现在项目里使用springboot,平时开发并不太关注springboot的一些基本配置,现在想整理一下springboot相关内容. 实际开发中都会因为各种业务需求在springboot上添加很多东 ...
- springboot 使用 freemarker 无法正常跳转的问题?
1.springboot 使用 freemarker 无法正常跳转的问题? 参考:https://blog.csdn.net/Lin_xiaofeng/article/details/79122053 ...
- springboot 整合 freemarker
springboot 整合 freemarker 依赖 <parent> <groupId>org.springframework.boot</groupId> & ...
随机推荐
- nginx 文件服务器配置,模板配置文件,有注释
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/e ...
- Mysql—修改用户密码(重置密码)
1.登录mysql [root@localhost ~]# mysql -uroot -p123456 [root@localhost ~]# mysql -hlocalhost -uroot -p1 ...
- 五分钟搞懂什么是B-树(全程图解)【转】
前戏 我们大家都知道动态查找树能够提高查找效率,比如:二叉查找树,平衡二叉查找树,红黑树.他们查找效率的时间复杂度O(log2n),跟树的深度有关系,那么怎么样才能提高效率呢?当然最快捷的方式就是减少 ...
- docker网络之(三)
docker4种网络 基于docker run创建容器时,可以使用--net选项指定容器的网络模式:Docker默认有以下4种网络模式: host模式,使用--net=host指定 container ...
- 6.Python网络编程_全局变量基础
变量作用域: 一般在函数体外定义的变量成为全局变量,在函数内部定义的变量称为局部变量.全局变量所有作用域都可用,局部变量只能在本函数可用,变量的使用顺序是,局部变量 > 全局变量, 也就是说:优 ...
- SpringBoot之异步定时任务
如果每个Scheduled方法是同步执行的,万一有一个发生死锁,那么其他任务就没法执行,下面介绍异步定时任务 异步定时任务 Spring为任务调度与异步方法执行提供了注解支持,即通过在方法上设置@As ...
- Redis windows版本资源与安装
这里提供一个windows版本的Redis百度云资源 链接: https://pan.baidu.com/s/19JY_d_J87n98OeAHK9qI4A 密码: d6dq 1,GitHub下载地址 ...
- C++ trais技术 模板特化的应用
// traits 的应用 /////////////////////////////////////////// // traits template <typename T> clas ...
- MySQL学习笔记1——DDL
DDL 1.数据库 *查看所有数据库:SHOW DATABASES;*切换(选择要操作的)数据库:USE 数据库名;*创建数据库:CREATE DATABASES [IF NOT EXISTS] my ...
- Python 可执行对象
Python 可执行对象 eval/repr eval eval 可以执行字符串类型的表达式 (或 compile() 创建的代码对象(code object) ) 并返回执行结果 eval(expr ...