SpringBoot整合FreeMarker
pom文件引入:
<!-- 引入freeMarker的依赖包. --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency>
在src/main/resources/创建一个templates文件夹,后缀为*.ftl
后台代码
@RequestMapping("/index")
public String index(Map<String, Object> map) {
map.put("name","美丽");
return"index";
}
前台代码
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8" /> <title></title> </head> <body> ${name} </body> </html>
访问:http://127.0.0.1:8080/hello

浙公网安备 33010602011771号