Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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
Javascript 当我们单击表中的每一行时,如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL?_Javascript_Jquery_Html_Spring Mvc_Mustache - Fatal编程技术网

Javascript 当我们单击表中的每一行时,如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL?

Javascript 当我们单击表中的每一行时,如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL?,javascript,jquery,html,spring-mvc,mustache,Javascript,Jquery,Html,Spring Mvc,Mustache,当我们单击表中的每一行时,如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL 我正在使用Mustache Spring MVC框架,其中来自MOngodb的所有数据都被检索到视图页面中的占位符上。因此,现在我需要让这些数据单击“启用”,单击时的每个数据行都需要重定向到不同的URL 这是我的桌子 <table> <tr> <th>Book Name</th> <th>Description</th

当我们单击表中的每一行时,如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL

我正在使用Mustache Spring MVC框架,其中来自MOngodb的所有数据都被检索到视图页面中的占位符上。因此,现在我需要让这些数据单击“启用”,单击时的每个数据行都需要重定向到不同的URL

这是我的桌子

<table>
  <tr>
    <th>Book Name</th>
    <th>Description</th>
  </tr>
  {{#books}}
  <tr>

    <td>{{book_name}}</td>

    <td>{{book_details}}</td>

  </tr>
  {{/books}}
</table>
输出类似于书籍列表及其说明


现在,当我单击book1时,它应该转到其他URL,当我单击book2时,它必须转到其他URL,依此类推,您可以尝试类似的方法。在这里,每个url都类似于某个url/书名


这必须是一个快速的解决方案

书名 描述 {{books}}
如果我正确理解你的问题,这将解决你的问题

添加一个特定于Bookbean的bool_url字段,比如bookurljava。 在向数据库添加图书时,您还需要指定图书的url

那么下面的内容对你有用

<table>
    <tr>
        <th>Book Name</th>
        <th>Description</th>
    </tr>
    {{#books}}
        <tr>
            <td><a href="{{book_url}}">{{book_name}}</a></td>
            <td>{{book_details}}</td>
        </tr>
    {{/books}}
</table>

什么是{{book_url}}?我该如何使用它呢?您需要触发的url,或者试试这个onclick=window.location=;实际上,当我发布的上述代码运行时,它会以表格格式显示书籍列表及其描述。现在,我要寻找的是,当我点击每本书时,它应该重定向到不同的URL,而点击书名或整行?只要书名是好的,你能举例说明哪些书重定向到哪些/不同的URL吗?这就是我需要的。。。如何重定向到不同的URL请阅读本教程:除了将链接包含到数据库中,还有其他方法吗?
<table>
    <tr>
        <th>Book Name</th>
        <th>Description</th>
    </tr>
    {{#books}}
        <tr>
            <td><a href="{{book_url}}">{{book_name}}</a></td>
            <td>{{book_details}}</td>
        </tr>
    {{/books}}
</table>