这篇文章,主要讲解几个Thymeleaf基本内置对象的使用。
#ctx
:模板引擎的全局上下文对象;
#locale
:在全局上下文中维护的java.util.Locale对象;
#request
:表示HttpServletRequest对象,只在Web环境下使用;
#response
:表示HttpServletResponse对象,只在Web环境下使用;
#session
:表示HttpSession对象,只在Web环境下使用;
#servletContext
:表示ServletContext对象,只在Web环境下使用。
通用使用方式:${#name.xxx}
,分别举例:
Controller
中:
request.setAttribute("name1", "value1");