【发布时间】:2015-02-06 09:31:42
【问题描述】:
我正在编写一个 java spring mvc web 应用程序,在客户端我使用引导程序和一个星级插件来表示对我向用户显示的歌曲列表的欣赏。
我正在做的是传递我在会话中生成的播放列表,并在 jsp 中迭代此列表以创建一个适合的表。在歌曲名称\标题旁边我想显示一个星级系统;我做到了,但它被设置为输入数字。我想要做的是,点击星号,重定向到另一个页面,在控制器中检索速率,进行一些逻辑,然后返回没有那首歌的播放列表页面。
我遇到了一些困难,因为在控制器上,要了解哪首歌被评分,我显然必须将歌曲的 id 作为输入参数,所以输入的名称类似于“input2838” ,但是在控制器端,当我必须请求具有RequestParameter 值的参数时,我需要准确指定我想要的参数的名称,所以我认为这不是正确的做法。
我向您询问有关如何执行此类操作的建议,最重要的是,当我单击该输入时,如何重定向到另一个页面,传递参数的值...
我向你展示了我在其中显示歌曲表的代码的 jsp sn-p。
<script>$("#input-id").rating();</script> <-- initialize the stars script
<c:choose> <-- when the playlist is not empty show it
<c:when test="${not empty playlist}">
<div class="container col-lg-10 col-lg-offset-1" >
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>#</th>
<th>Cover</th>
<th>Artista</th>
<th>Titolo</th>
<th>Rate</th>
</tr>
</thead>
<tbody>
<c:forEach items="${playlist}" var="canzone" varStatus="count">
<tr style="font-weight: normal">
<td style="font-weight: normal">${count.index +1}</td>
<td style="font-weight: normal"><img src="${canzone.albumImageUrl}" /></td>
<td style="font-weight: normal">${canzone.artistName}</td>
<td class="col-lg-4" style="font-weight: normal">${canzone.title}</td>
<td class="col-lg-4" style="font-weight: normal"><div><input id="input-id" type="number" class="rating" min=0 max=5 step=1 data-size="xs" data-rtl="false"></div></td>
<tr>
</c:forEach>
</tbody>
</table>
</div>
</c:when>
<c:otherwise>
为了完整起见,现在我将星级 js 发布为 pastebin 链接:
不要犹豫,询问其他信息。
【问题讨论】:
标签: java javascript html spring controller