@Controller @RequestMapping("ftl") public class FreemarkerController { @Autowired private Resource resource; @RequestMapping("/index") public String index(ModelMap map){ map.addAttribute("resource", resource); return "freemarker/index"; } @RequestMapping("center") public String center(){ return "freemarker/center/center"; } @RequestMapping("test") public String test(){ return "test"; } }
检查以下几点
pom.xml文件里是否加了freemarker依赖
application.properties 是否添加了 freemarker的配置
src/main/resources/templates/freemarker目录下是否有index.ftl文件