SpringBoot2.x整合模板引擎thymeleaf


代码:
	
	
	
	    
	    Title
	
	
	这是小滴课堂 thymeleaf 整合index.html页面
	
	
	

package com.example.Maven.Project.controller; import com.example.Maven.Project.config.WXConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Controller @RequestMapping("tpl") public class FreeMarkerController { @Autowired private WXConfig wxConfig; @GetMapping("freemaker") public String index1(ModelMap modelMap){ modelMap.addAttribute("setting",wxConfig); //不用加后缀,因为配置文件里面已经指定了后缀 return "fm/index"; } @GetMapping("thymeleaf") public String index2(ModelMap modelMap){ modelMap.addAttribute("setting",wxConfig); //不用加后缀,因为配置文件里面已经指定了后缀 return "tl/index"; } }