springboot中如何整合freemarker
发表于:2025-02-09 作者:千家信息网编辑
千家信息网最后更新 2025年02月09日,这篇文章主要介绍"springboot中如何整合freemarker"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"springboot中如何整合freemar
千家信息网最后更新 2025年02月09日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(Mapmap){ String dataUrl = "http://localhost:31001/cms/config/getmodel/5a791725dd573c3574ee333f"; ResponseEntity
关于"springboot中如何整合freemarker"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。
整合
姓名
年龄
模板
知识
行业
逗号
不同
实用
位置
内容
参数
地址
大小
字符
字符串
实用性
实际
序号
开户行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
国外服务器那个好
实验7数据库安全性控制
软件开发进度收入会计分录
2020网络安全教育日是
方舟服务器直连没有响应
北京都安居网络技术有限公司
网络安全专业手抄报
全球网络安全隐患
网络安全销售基本工资
福州网络安全培训机构实战教学
程序化交易 软件开发
乐刻网络技术
机器人服务器怎么调整
惠州市通洲网络技术
服务器断电重启和热重启
畜牧中心网络安全责任制
pg数据库压缩表
服务器替换配件失败的影响
毅达资本 网络安全
网络安全主要学习什么
信息网络安全在生产的影响
邮箱地址数据库有哪些
昌吉云服务器口碑推荐
网络安全自渗透工具
传奇游戏网关服务器未开启
流媒体服务器硬件配置
怎样关闭数据库中的查询页面
网络安全审计面试提问
数据库怎么查
鹏成医院管理系统连接不上服务器