我创建了 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
}