我是靠谱客的博主 专注柜子,这篇文章主要介绍springboot-集成freemakerspringboot-集成freemaker,现在分享给大家,希望可以做个参考。

springboot-集成freemaker

1,添加依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

2,添加 index.ftl 文件

index.ftl 文件放在 resource/template 目录下
ftl 支持 jstl 语法

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8"/>
<title></title>
</head>
<body>
${name}
</body>
</html>

3,编写 controller 类

package com.test.freemarker;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
*
*/
@Controller
public class IndexController {
@RequestMapping("/index")
public String index(ModelMap map){
map.addAttribute("name", "张三");
return "index";
}
}

最后

以上就是专注柜子最近收集整理的关于springboot-集成freemakerspringboot-集成freemaker的全部内容,更多相关springboot-集成freemakerspringboot-集成freemaker内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(141)

评论列表共有 0 条评论

立即
投稿
返回
顶部