Spring Boot Thymeleaf URL 链接

Spring Boot Thymeleaf About 345 words

@{}

使用@{}表示URL链接,GET请求中使用()表示请求参数。

<link rel="shortcut icon" th:href="@{/favicon.ico}">

<a th:href="@{/sitemap.xml}">网站地图</a>

<a th:href="@{/(page=${page + 1})}">下一页</a>

||

在请求参数()中可以使用${}来获取变量,但在主路径上无法使用,th:href="@{/p/${id}}"代码是不生效的。

使用||拼接字符串的方式,在主路径中获取变量。

<a th:href="|/p/${post.id}.html|" >标题</a>
Views: 322 · Posted: 2023-08-29

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh