Java web用springboot开发web application时,前端部分用thymeleaf模板引擎,现在希望页面可以组装,就是头部单独写,每个页面都用那个头部,尾部等一样,就像php的blade。
查阅thymeleaf的文档发现是提供了继承的,th:fragment和th:replace就可以完成我希望的工作。
但是现在在yeoman这一套前端开发流程下,里面是纯的HTML,不能试试预览是否有效果。
怎么更好地解决这个问题,或者说有什么方法可以更方便地写java web的前端么?
Thymeleaf template file is a well-formatted HTML file, so you can open it directly to see the effect. Based on this purpose, the inheritance and replacement of Thymeleaf actually requires the header of each file to be written repeatedly. If it is not written repeatedly, the purpose of directly opening and viewing the effect cannot be achieved. So whether you need to open every page to see the effect, there is a choice here. You can refer to Demo: https://github.com/thymeleaf/thymeleafexamples-petclinic