HTML代码:

<a href="https://www.example.com" target="_blank">前往网址</a>

Thymeleaf代码:

<a th:href="@{https://www.example.com}" target="_blank">前往网址</a>

Spring Boot与Thymeleaf集成时,可以使用Thymeleaf模板引擎渲染HTML页面。上述Thymeleaf代码中,@{}中的内容表示一个表达式,用于生成URL地址。th:href属性用于将生成的URL地址作为链接的目标。target="_blank"用于设置链接在新的页面中打开。


原文地址: https://www.cveoy.top/t/topic/fcj0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录