【问题标题】:Thymeleaf - Click able URL (Web link) in TableThymeleaf - 表中可点击的 URL(Web 链接)
【发布时间】:2019-05-07 05:13:34
【问题描述】:

(我在谷歌上看过,这里..并没有找到可以帮助我的答案)。

目标:作为可点击网页链接输入的网站 - 从数据库中检索链接作为 varchar(100)

尝试了各种不同的解决方案.. 没有任何运气 - 也许你们中的一个可以帮助我? :)。提前谢谢你。

 <table class="table table-striped table-bordered table-hover">

    <thead>

    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Address</th>
        <th>City</th>
        <th>Zip</th>
        <th>Website</th>
        <th>Email</th>
        <th>Phone</th>
        <th>Location</th>
        <th>Agelimit</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="sps: ${sp}">
        <td th:text="${sps.venueId}"/>
        <td th:text="${sps.name}"/>
        <td th:text="${sps.address}"/>
        <td th:text="${sps.city}"/>
        <td th:text="${sps.zip}"/>
        <td th:text="${sps.website}"/>
        <td th:text="${sps.email}"/>
        <td th:text="${sps.phone}"/>
        <td th:text="${sps.location}"/>
        <td th:text="${sps.ageLimit}"/>


    </tr>
    </tbody>
</table>

【问题讨论】:

    标签: java html spring-boot thymeleaf


    【解决方案1】:

    您可以在 Thymeleaf 中使用任何类型的标签。这是你想要的吗?

    <td>
        <a th:href="${sps.website}" th:text="${sps.website}" target="_blank" />
    </td>
    

    【讨论】:

    • Metroids - 谢谢!它现在几乎可以工作了,现在可以点击了,但它确实链接:localhost:8080/detailsvenue_admin/www.rust.dk 而不仅仅是rust.dk,因为它应该?。
    • Whitelabel 错误页面 此应用程序没有明确的 /error 映射,因此您将其视为后备。 2018 年 12 月 5 日星期三 16:42:35 CET 出现意外错误(类型=错误请求,状态=400)。无法将“java.lang.String”类型的值转换为所需的“int”类型;嵌套异常是 java.lang.NumberFormatException: For input string: "www.rust.dk"
    • 您应该将完整的 url 存储在数据库中...您应该有 http://rust.dkhttps://rust.dk
    • 如果我想用表格中的 LINK 更改实际的 URL(有时 URL 很长) - 当你点击 LINK 时它会执行实际的 URL?
    • 谷歌地图 - “谷歌地图”现在是可点击的链接。
    猜你喜欢
    • 2021-11-15
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2022-11-13
    • 2015-02-13
    相关资源
    最近更新 更多