我有一个index.jsp每个春季mvc 3.x,其中包含一个下拉列表框。
什么是最简单的方式回发到相同的页面,但查询对每个选定的项目在列表中?
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.
} 发布于 2013-08-28 05:28:30
试试return "redirect:index?item=" + selectList;
发布于 2013-08-28 10:48:54
尝试ajax进行表单提交。
var str =$(“#myForm”).serialize()
$.ajax({ type:"post",data:str,url:"indexSubmit",异步: false,dataType:"json",dataType: function(){警告(“成功”);});
https://stackoverflow.com/questions/18479606
复制相似问题