Home > Common Problem > What are the built-in objects of thymeleaf?

What are the built-in objects of thymeleaf?

小老鼠
Release: 2023-11-09 11:36:38
Original
1574 people have browsed it

Thymeleaf built-in objects include #ctx, #request, #response, #session, #servletContext, #locale, #httpServletRequest, #httpServletResponse, #httpSession, #servletContext, #authentication, #authorization, etc.

What are the built-in objects of thymeleaf?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template