当我们点击 table 中的每一行时,如何重定向到不同的 URL,即点击每一行元素必须重定向到不同的 URL?
How to redirect to different URLs when we click on each row in the table i.e, click on each row element must redirect to different URLs?
当我们点击 table 中的每一行时,如何重定向到不同的 URL,即点击每一行元素必须重定向到不同的 URL?
我正在开发 Mustache Spring MVC 框架,其中来自 MOngodb 的全部数据被检索到视图 page.So 中的占位符上,现在我需要点击此数据单击时启用和每个数据行需要重定向到不同的 URLs
这是我的 table
<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 都会像 some_url/book_name
.
<tr>
<td>
<a href="./some_url{{book_name}}">{{book_name}}</a>
</td>
<td>{{book_details}}</td>
</tr>
这一定是一个快速的解决方案
<table>
<tr>
<th>Book Name</th>
<th>Description</th>
</tr>
{{#books}}
<tr>
<td onclick="window.location='{{book_url}}';>{{book_name}}</a></td>
<td>{{book_details}}</td>
</tr>
{{/books}}
</table>
如果我正确理解你的问题,这将解决你的问题
向您的 Book
bean 添加一个字段 bool_url
(例如 bookUrl
java 特定)。
在将 book
添加到数据库时,您还需要指定 book_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>
当我们点击 table 中的每一行时,如何重定向到不同的 URL,即点击每一行元素必须重定向到不同的 URL?
我正在开发 Mustache Spring MVC 框架,其中来自 MOngodb 的全部数据被检索到视图 page.So 中的占位符上,现在我需要点击此数据单击时启用和每个数据行需要重定向到不同的 URLs
这是我的 table
<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 都会像 some_url/book_name
.
<tr>
<td>
<a href="./some_url{{book_name}}">{{book_name}}</a>
</td>
<td>{{book_details}}</td>
</tr>
这一定是一个快速的解决方案
<table>
<tr>
<th>Book Name</th>
<th>Description</th>
</tr>
{{#books}}
<tr>
<td onclick="window.location='{{book_url}}';>{{book_name}}</a></td>
<td>{{book_details}}</td>
</tr>
{{/books}}
</table>
如果我正确理解你的问题,这将解决你的问题
向您的 Book
bean 添加一个字段 bool_url
(例如 bookUrl
java 特定)。
在将 book
添加到数据库时,您还需要指定 book_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>