Jsp代码从表中的一行获取。

<li>
    <a href="otherpageJsp?idParam1=${value1}&idParam2=${value2}"
          onclick="otherpageJsp">Somelinktext</a>
</li>


在模型和视图中

@RequestMapping(value = "otherpageJsp")
public ModelAndView goPage(@RequestParam String idParam1,String idParam2, Model model) {
    ModelAndView mav = new ModelAndView("otherpageJsp");
    mav.addObject("current", "otherpageJsp");
    mav.addObject("value1", idParam1);
    mav.addObject("value2", idParam2);
    return mav


调用onclick()时,我只会得到value1,value2 = null。有人可以帮我解决这个问题吗?

最佳答案

只需添加@RequestParam即可将参数值设置为方法的参数。

public ModelAndView goPage(@RequestParam String idParam1,@RequestParam String idParam2, Model model) {

08-03 17:33