springboot中如何整合freemarker
来源:亿速云
2024-04-11 14:18:11
0浏览
收藏
今日不肯埋头,明日何以抬头!每日一句努力自己的话哈哈~哈喽,今天我将给大家带来一篇《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: 8001 spring: application: name: test-freemarker freemarker: cache: false settings: template_update_delay: 0 template-loader-path: classpath:/templates/
启动类
@SpringBootApplication public 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 <#if model??> <#list model as item> #list> #if>
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
今天带大家了解了的相关知识,希望对你有所帮助;关于文章的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~
版本声明
本文转载于:亿速云 如有侵犯,请联系study_golang@163.com删除

- 上一篇
- PHP 函数惰性求值:优化性能并节省内存

- 下一篇
- 苹果iOS 17.4.1内部测试曝光,或本周下周亮相
查看更多
最新文章
-
- 文章 · java教程 | 3小时前 | 数组 foreach ArrayIndexOutOfBoundsException 静态初始化 动态初始化
- Java数组定义与两种初始化技巧
- 412浏览 收藏
-
- 文章 · java教程 | 5小时前 |
- 在IntelliJIDEA中如何设置按键的toast提示?
- 415浏览 收藏
-
- 文章 · java教程 | 1天前 | SQLException nullpointerexception IOException 非受检异常 受检异常
- Java常见异常类型与触发条件详解
- 265浏览 收藏
-
- 文章 · java教程 | 1天前 | 动态调整 数组定义 arrays.copyof new关键字 直接初始化
- Java数组定义方法大全及对比
- 145浏览 收藏
-
- 文章 · java教程 | 1天前 | 数据类型 数组定义 数组长度 nullpointerexception ArrayIndexOutOfBoundsException
- Java数组定义与声明语法详解
- 349浏览 收藏
-
- 文章 · java教程 | 1天前 | 封装 class 构造函数 getter/setter 私有属性
- Java类定义及成员声明全面解析
- 321浏览 收藏