【发布时间】:2015-04-04 17:04:54
【问题描述】:
假设我在 Spring Web 应用程序视图中有一个对象列表。假设这些对象是论坛线程。他们每个人都有一个链接,该链接将移动到包含该线程所有主题的页面。现在为了列出这些主题,我需要保留被选中的线程 ID。包含链接的 .jsp 部分:
<h3><spring:message code="label.threadList"/></h3>
<c:if test="${!empty threadList}">
<table class="data">
<tr>
<th><spring:message code="label.threadName"/></th>
<th><spring:message code="label.threadDescription"/></th>
<th><spring:message code="label.threadTopicCount"/></th>
<th><spring:message code="label.threadLastModified"/></th>
<th>Go</th>
</tr>
<c:forEach items="${threadList}" var="thread">
<tr>
<td>${thread.name} </td>
<td>${thread.description} </td>
<td>${thread.topics}</td>
<td>${thread.last_modified}</td>
<td><a href="topics.html">Open</a></td>
</tr>
</c:forEach>
</table>
现在,据我了解,我需要通过请求映射来获取参数:
@Controller
public class TopicPageController {
@RequestMapping(value = "/topics", method = RequestMethod.GET)
public ModelAndView helloWorld(@RequestParam("getId") int getId) {
System.out.println(getId); //here's when I want to see the param
return new ModelAndView();
}
}
我不能做对的是通过它。我怎么能包括,点击这个链接,请求会得到那个参数?
【问题讨论】:
标签: java spring hyperlink parameters request