Spring Boot 3 Thymeleaf 获取 HTTP 状态码

Spring Boot Thymeleaf About 227 words

ctx

Thymeleaf提供了#ctx可以获取Status Code

思路

通过ctx获取到HttpServletResponse就能获取状态码了。

代码

#ctx.getExchange().getNativeResponseObject().getStatus()

<p th:text="${#ctx.getExchange().getNativeResponseObject().getStatus()}"></p>
Views: 129 · Posted: 2024-03-21

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh