【问题标题】:Using Thymeleaf to create links that open in a new window/tab使用 Thymeleaf 创建在新窗口/选项卡中打开的链接
【发布时间】: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 完成。

标签: java html thymeleaf


【解决方案1】:

Thymeleaf 覆盖 a 标记。使用th:target="_blank"

【讨论】:

  • 完整示例<a th:href="@{https://MY-URL}" th:target="_blank">
猜你喜欢
  • 2013-03-22
  • 2012-01-22
  • 2011-02-18
  • 1970-01-01
  • 2013-06-12
  • 2013-11-11
  • 2013-03-11
  • 2010-09-12
相关资源
最近更新 更多