Spring Boot 3 Thymeleaf ctx 对象

Spring Boot Thymeleaf About 847 words

ctx

Thymeleaf中提供的#ctxWebEngineContext对象。

<p th:text="${#ctx}"></p>

输出

class org.thymeleaf.context.WebEngineContext

获取 HttpServletRequest

<p th:text="${#ctx.getExchange().getRequest()}"></p>

输出

class org.thymeleaf.web.servlet.JakartaServletWebRequest

获取 HttpServletResponse

<p th:text="${#ctx.getExchange().getNativeResponseObject()}"></p>

输出:FirewalledResponse实现了HttpServletResponse

class org.springframework.security.web.firewall.FirewalledResponse

获取 HttpSession

<p th:text="${#ctx.getExchange().getSession()}"></p>

输出

class org.thymeleaf.web.servlet.JakartaServletWebSession

获取 WebExchange

<p th:text="${#ctx.getExchange()}"></p>

输出

class org.thymeleaf.web.servlet.JakartaServletWebExchange

如果使用

找到对应的类:WebEngineContextJakartaServletWebRequestHttpServletResponse,直接使用其public的方法即可。

Views: 129 · Posted: 2024-03-22

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh