资源
- MVNRepository
- 官方参考手册
- FreeMarker 中文参考手册(对应版本:v2.3.23,仅做参考使用)
- 中文手册(对应版本:v2.3.28)
POM
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-freemarker -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
使用
新建src/main/resources/templates
文件夹,添加index.ftlh
文件:
<!doctype html>
<html class="no-js" lang="zh">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation Starter Template</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/css/foundation.min.css" integrity="sha256-xpOKVlYXzQ3P03j397+jWFZLMBXLES3IiryeClgU5og=" crossorigin="anonymous" />
</head>
<body>
<h1>Hello, world!</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/what-input/5.1.3/what-input.min.js" integrity="sha256-bj9uUXCtgWia8MCh9s6lkvAbenPi2xgxdyH5qfPrAVk=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.5.3/js/foundation.min.js" integrity="sha256-/PFxCnsMh+nTuM0k3VJCRch1gwnCfKjaP8rJNq5SoBg=" crossorigin="anonymous"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
在控制器中返回视图:
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
return "index";
}