【发布时间】:2017-03-01 20:30:05
【问题描述】:
在基本 HTML 中,链接可以具有 target="_blank" 属性以强制它在新窗口或标签中打开。但是,如果我把它放在还包含 Thymeleaf 的 th:href 的 <a href> 标签中,Thymeleaf 会覆盖整个标签并清除我的 target="_blank。
我考虑过将target="_blank" 添加到每个链接的蛮力方法,因为它存储在我的数据库中,因此当Thymeleaf 写出它时它已经是链接的一部分。但我更喜欢让 Thymeleaf 编写 target="_blank" 属性的方法,因为它正在编写 <a> 标记。
【问题讨论】:
-
改用
th:target="_blank" -
谢谢@conscells。我试试看!
-
th:target="_blank"有效! -
@MrLister 完成。