我每个 spring mvc 3.x 都有一个 index.jsp,其中包含一个下拉列表框。
什么是最简单的回发到同一页面但每个列表中选定项目的查询参数的方法?
myPage/index.jsp(http://localhost:8085/mypage)
<form class="form-horizontal" action="myController/indexSubmit" method="post">
<select name="selectList" class="form-control" placeholder=".input-medium" height>
<c:forEach items="${theList}" var="item" varStatus="count">
<option value="${count.index}">${item }</option>
</c:forEach>
</select>
<button type="submit" class="btn btn-primary btn-medium">Submit</button>
</form>
->http://localhost:8085/GameAnalytics?selectedItem=3
我尝试使用回发重定向回 /index 似乎不起作用。
@RequestMapping(value="indexSubmit", method = RequestMethod.POST)
public String indexSubmit( @RequestParam String selectList, ModelMap model) {
System.out.println("Selected Title: " + selectList);
return "forward:/index?item=" + selectList; // add query params and redirect back to main index page.
}