php做电影网站有哪些,平江高端网站建设,长春网站排名优化价格,做园林景观的网站模版引擎
常见的模版引擎有JSP、Velocity、Freemarker和Thymeleaf
Thymeleaf模版
使用时需要把html页面放在classpath#xff1a;/templates/文件夹下#xff0c;thymeleaf就能自动渲染创建模版文件#xff0c;并需要导入thymeleaf的名称空间 html langen/templates/文件夹下thymeleaf就能自动渲染创建模版文件并需要导入thymeleaf的名称空间 html langen xmlns:thhttp://www.thymeleaf.org 使用模版 !DOCTYPE html
html langen xmlns:thhttp://www.thymeleaf.org
headmeta charsetUTF-8title[[${title}]]/title
/head
body
h1 th:text${title}/h1
div th:text${info}这里的文本之后将会被覆盖/div
/body
/html 在controller里面准备模版需要的数据 Controller
public class HelloT {RequestMapping(/ht)public String ht(Model model) {model.addAttribute(title,hello Thymeleaf).addAttribute(info,this is first thymeleaf test);return t1;}
}
语法规则
thtext --》改变元素里面的文本内容
th任意的html属性 --》替换原生的属性的值html属性值只要加上了th就相当于兼容了Thymeleaf模版
参考文档中文参考