五、SpringBoot集成模版引擎

一、什么是模版引擎

就是伪html,格式是html,但是可以像jsp那样有动态数据,也可以说是动态页面静态化。

二、有什么作用

可以提高搜索引擎的搜索

三、有那些模版引擎

velocity 、Thymeleaf、framemaker
velocity相关资料

http://velocity.apache.org

Thymeleaf

官方资料:https://www.thymeleaf.org/documentation.html
其它资料1:https://blog.csdn.net/u014042066/article/details/75614906
其它资料2https://www.cnblogs.com/summercanon/p/7910799.html

framemaker

中文教程文档:https://download.csdn.net/download/ch656409110/4494063

四、使用案例

这里使用:Thymeleaf 作为模版引擎为例:这里只是参考一下。第五步会有完整案例

上代码:

1、控制层
@Controller
public class ThymeleafTestController {
    private Logger logger = LoggerFactory.getLogger(ThymeleafTestController.class);
    
@RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String hello(Map maps){
        maps.put("name","张三");
        maps.put("sex","男");
        return "index";
    }
}
2、页面代码




    
    首页



3333

aaa

3、效果
效果

五、完整步骤集成到SpringBoot

点这里完整步骤集成到SpringBoot

看相关其它文章先到:目录大岗

你可能感兴趣的:(五、SpringBoot集成模版引擎)