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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复