Thymeleaf built-in objects include #ctx, #request, #response, #session, #servletContext, #locale, #httpServletRequest, #httpServletResponse, #httpSession, #servletContext, #authentication, #authorization, etc.
Operating system for this tutorial: Windows 10 system, Dell G3 computer.
Thymeleaf is a server-side Java template engine for building dynamic web applications. In Thymeleaf, there are some built-in objects that can be used directly in templates. The following are some common Thymeleaf built-in objects:
#ctx: Context object, representing the context information of the current request.
#request: HttpServletRequest object, representing the current requested HttpServletRequest.
#response: HttpServletResponse object, representing the current requested HttpServletResponse.
#session: HttpSession object, representing the HttpSession of the current request.
#servletContext: ServletContext object, representing the ServletContext of the current Web application.
#locale: Locale object, indicating the locale of the current request.
#httpServletRequest: Alias of HttpServletRequest object, the same as #request.
#httpServletResponse: Alias of HttpServletResponse object, the same as #response.
#httpSession: Alias of HttpSession object, the same as #session.
#servletContext: Alias of ServletContext object, the same as #servletContext.
#authentication: Spring Security's Authentication object, representing the current user's authentication information.
#authorization: Spring Security's Authorization object, representing the current user's authorization information.
These built-in objects can be used directly in Thymeleaf templates, through which you can easily obtain and operate request-related information. It should be noted that Thymeleaf's built-in objects are provided based on the characteristics of the Spring MVC framework, so when using Thymeleaf, you need to use these built-in objects in conjunction with Spring MVC.
The above is the detailed content of What are the built-in objects of thymeleaf?. For more information, please follow other related articles on the PHP Chinese website!