创建一个templates
@Controller
public class HelloController {
@GetMapping("/basic")
public String hello(Model model){
Student student = new Student();
student.setName("小明");
student.setAge(18);
model.addAttribute("stu",student);
return "01-basic";
}
报错。。。。
。。。yml配置没有问题。
// An highlighted block
spring:
http:
encoding:
force: true
charset: UTF-8
freemarker:
allow-request-override: false
cache: false
check-template-location: true
charset: UTF-8
content-type: text/html; charset=utf-8
expose-request-attributes: false
expose-session-attributes: false
expose-spring-macro-helpers: false
suffix: .ftl
template-loader-path: classpath:/templates
原来是少加了freemarker依赖,加上就好了