0
一般我們可以在控制器中得到JSP領域這樣的貼值:如果一個字段是這是一個多重選擇的元素出現如何獲得選擇倍數的值?
@Controller
public class someClass {
@RequestMapping(value = "/someUrl", method = RequestMethod.POST)
public ModelAndView someMethodName(@RequestParam Map<String, String> params) {
for (Map.Entry<String, String> param : params.entrySet()) {
// field name is got from param.getKey() , field value is got from param.getValue()
}
return new ModelAndView("redirect:/someOtherUrl");
}
}
的問題。那麼如何獲得從中選擇的值?
我總是得到即使我選擇多個選項只有一個值! NB:我測試了select元素的'name'屬性,並且沒有'[]' – pheromix
哦,我誤解了。根據http://stackoverflow.com/questions/2407945/how-to-get-multiple-selected-values-from-select-box-in-jsp我會嘗試使用地圖或列表,而不是地圖 –
rob
你應該改變你的答案,因爲你最後的評論提到的鏈接是正確的答案:) – pheromix