Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在列表中每个元素(字符串)的末尾添加链接?使用胸腺素_Html_Css_Thymeleaf - Fatal编程技术网

Html 如何在列表中每个元素(字符串)的末尾添加链接?使用胸腺素

Html 如何在列表中每个元素(字符串)的末尾添加链接?使用胸腺素,html,css,thymeleaf,Html,Css,Thymeleaf,我正在从列表中一行一行地提取文本,我需要在每行的末尾添加一个超链接。正在尝试下面的代码,但未显示链接 <p th:each="releases : ${release}" class="releases" th:text="${releases}" th:href="www.abc.com"> New Releases </p> 新版本 试试这个 <p th:each="releases : ${release}" th:href="www.abc

我正在从列表中一行一行地提取文本,我需要在每行的末尾添加一个超链接。正在尝试下面的代码,但未显示链接

    <p  th:each="releases : ${release}"
  class="releases" th:text="${releases}" th:href="www.abc.com"> New Releases </p>

新版本

试试这个

<p  th:each="releases : ${release}" th:href="www.abc.com"> <span class="releases" th:text="${releases}"> New Releases </span> </p>

新版本


如果要在每个“发布”字符串的末尾添加链接,可以使用以下方法:

<p th:each="releases : ${release}"
    class="releases">
    <span th:text="${releases}"></span>
    <a th:href="@{www.abc.com/${rel}(rel=${releases})}" 
       th:text=" '[link]'"></a>
</p>
每个链接文本都有一个自定义的href。

<p  th:each="releases : ${release}">  <span class="releases" th:text="${releases.split('Spotify')[0]}"> 
    New Releases </span> <a class="spoturl" th:href="${releases.split('URL:\s')[1]}"> Spotify URL </a> </p>
新版本


我的解决方案

谢谢您的回答。事实上,我解决问题的方式与上一个答案类似。@IljaVeselov-欢迎你提供(甚至接受)你自己的答案,解释你是如何解决问题的。
<p  th:each="releases : ${release}">  <span class="releases" th:text="${releases.split('Spotify')[0]}"> 
    New Releases </span> <a class="spoturl" th:href="${releases.split('URL:\s')[1]}"> Spotify URL </a> </p>