我创建了JS数组,然后尝试将该数组传递给Controller类,但是它显示了NullPointerException

我通过FireBug检查URL,那里的值正在传递,但是在控制器类中,如果我尝试检索该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[]

09-12 08:03