bootstrap5模板,Spring Boot 9-FreeMarker模板引擎

 2023-10-21 阅读 19 评论 0

摘要:springboot使用freemarker模板引擎首先引入freemarker <!-- freemarker依賴包 --> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId> </dependency> ? 編寫ftl文
springboot使用freemarker模板引擎

首先引入freemarker
<!-- freemarker依賴包 -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

?

編寫ftl文件,注意默認放在resource/templates/下,也可以在application.yml重新定義
hello freemarker!${name}
<#if sex="0"><#else></#if>

bootstrap5模板,?

spring:freemarker:cache: falsetemplate-loader-path: classpath:/templates/suffix: .ftl

?

編寫控制類
package com.tzp.freemarker.controller;import java.util.Map;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
public class FreeMarkerController {@RequestMapping("/ftlindex")public String index(Map<String, Object> result) {result.put("sex", "0");result.put("name", "xxx");return "index";}}

template模板引擎,?

測試效果

?

?

jstemplate模板引擎?轉載于:https://www.cnblogs.com/zengpingtang/p/10810058.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/154509.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息