Spring Boot 3 Thymeleaf ctx 对象
Spring Boot Thymeleaf About 847 wordsctx
Thymeleaf
中提供的#ctx
是WebEngineContext
对象。
<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
如果使用
找到对应的类:WebEngineContext
、JakartaServletWebRequest
、HttpServletResponse
,直接使用其public
的方法即可。
Views: 437 · Posted: 2024-03-22
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...