Reputation: 47
I created the JS array and try to pass the array to the Controller class, but there it is showing the NullPointerException
.
I checked the URL through FireBug there the values are passing but in controller class if I try to retrive it is showing NULL.
JavaScript Code:
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 Code (In controller class):
@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
}
Upvotes: 2
Views: 5404
Reputation: 4511
You have to specify the name of the request parameter within the annotation:
@RequestMapping(value = "/saveLayout")
public ModelAndView saveLayout(@RequestParam(value="deleteWidgetId") String[] deleteWidgetId) throws Exception {
//here that if i try to use the deleteWidgetId it is giving null pointer exception
}
Upvotes: 1