springBoot---整合freemarker ftl
1.首先导入jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
2.查看导入的包,确定已经导入过来了
3.导入成功之后,给自己写的包进行分层
4.然后我们编写我们的controller层的代码
package demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@Controller
public class FreemarkerIndexController {
@RequestMapping("/freemarkerIndex")
public String freemarkerIndex(Map<String,String> result, HttpServletRequest request){
result.put("welcome","hello");
return "freemarkerIndex";
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
this is welcome ${welcome}
</body>
</html>
5.进行启动
6.查看启动之后内容
沫笙