springboot中如何整合freemarker
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,这篇文章主要介绍"springboot中如何整合freemarker"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"springboot中如何整合freemar
千家信息网最后更新 2026年11月02日springboot中如何整合freemarker
姓名:${stuMap['stu1'].name}年龄: ${stuMap.stu1.age}<#list stuMap?keys as k> 姓名: ${stuMap[k].name} 年龄: ${stuMap[k].age}#list>${stuMap???c}//判断是否存在,和使用 ?c 输出字符串${students???c}${(mozq.bank.address)!'中国建设银行'}//默认值方式处理空值${students?size}//集合大小<#assign text="{'bank':'中国农业银行', 'address':'北大街'}"><#assign data=text?eval>开户行: ${data.bank} 地址: ${data.address}${123456123?c}//不显示逗号分隔${123456123}//默认显示逗号分隔
这篇文章主要介绍"springboot中如何整合freemarker"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"springboot中如何整合freemarker"文章能帮助大家解决问题。
依赖
org.springframework.boot spring-boot-starter-parent 2.1.6.RELEASE org.springframework.boot spring-boot-starter-freemarker org.projectlombok lombok com.squareup.okhttp3 okhttp 3.9.1 commons-io commons-io 2.6 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test
application.yml
application 参数路径
server: port: 8001spring: application: name: test-freemarker freemarker: cache: false settings: template_update_delay: 0 template-loader-path: classpath:/templates/
启动类
@SpringBootApplicationpublic class FreemarkerApplication { public static void main(String[] args) { SpringApplication.run(FreemarkerApplication.class, args); } @Bean public RestTemplate restTemplate(){ return new RestTemplate(new OkHttp3ClientHttpRequestFactory()); }}模板文件
| 序号 | 姓名 | 年龄 | 金钱 | 出生日期 |
| ${stu_index} | #if> >${stu.name} | #if>>${stu.age} | ${stu.money} | ${stu.birthday?date},${stu.birthday?time},${stu.birthday?string("yyyy年MM月dd日")} |
Title
Controller
package com.mozq.springboot.freemarker.controller;import com.mozq.springboot.freemarker.model.Student;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.client.RestTemplate;import java.util.*;@Controller //注意不要使用 @RestController@RequestMapping("/freemarker")public class FreeMarkerController { @Autowired private RestTemplate restTemplate; @RequestMapping("/banner") public String banner(Map map){ String dataUrl = "http://localhost:31001/cms/config/getmodel/5a791725dd573c3574ee333f"; ResponseEntity 关于"springboot中如何整合freemarker"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。
整合
姓名
年龄
模板
知识
行业
逗号
不同
实用
位置
内容
参数
地址
大小
字符
字符串
实用性
实际
序号
开户行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
咖啡网
咖啡豆
中智农互联网科技
博彦科技互联网金融
广州万易互联网科技有限公司
华服互联网科技怎么样
涨乐互联网科技
盈实互联网科技
科技类互联网
与互联网科技公司
高科技与互联网
猪兼强互联网科技
北京互联网络科技有限公司
互联网科技博客
富国互联网科技创新基金
江苏南京365互联网科技
民营互联网公司国防科技
工业互联网等科技实现智能化赋能
互联网领先科技活动
银川新华互联网科技学校招聘
小米移动互联网科技园
喔噻互联网科技有限公司
广州互联网科技公司
赫美联合互联网科技
互联网科技小额贷款
天下捷融互联网科技
汽车互联网创新科技园
烟台灵鸽互联网科技有限公司
云南省自由互联网科技有限公司
广州燕处互联网科技有限公司