我创建了 JS 数组并尝试将数组传递给 Controller 类,但它显示了NullPointerException
.
我通过 FireBug 检查了 URL,其中值正在传递,但在控制器类中,如果我尝试检索它,则显示 NULL。
JavaScript 代码:
var deleteWidgetId = new Array(); //array created
deleteWidgetId[0] = "a";//adding values
deleteWidgetId[1] = "b";
//action trigged
$("#saveLayout").load("layout/saveLayout.action",
{ deleteWidgetId : deleteWidgetId },
function(response, status, xhr) { });
Java代码(在控制器类中):
@RequestMapping(value = "/saveLayout")
public ModelAndView saveLayout(@RequestParam String[] deleteWidgetId) throws Exception {
//here that if i try to use the deleteWidgetId it is giving null pointer exception
}
尝试使用List<String>
代替String[]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)