第二章、Thymeleaf 基础知识

变量表达式  ${...}(美元表达式),用于访问容器上下文环境中的变量,功能同jstl中的${}

protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
	throws ServletException, IOException {
	...
	//Create Servlet context
	WebContext ctx = new WebContext(req, resp, this.getServletContext(), req.getLocale());
	ctx.setVariable("helloword","hello thymeleaf,wellcome!");
	//Executing template engine
	templateEngine.process("home", ctx, resp.getWriter());
}

获取 helloword变量的值

输出的值   hello thymeleaf,wellcome!

消息表达式  #{...}(井号表达式,资源表达式)。通常与th:text属性一起使用,指明声明了th:text的标签的文本是#{}中的key所对应的value,而标签内的文本将不会显示。


注意:

你可能感兴趣的:(第二章、Thymeleaf 基础知识)