I am struggling to successfully send an array from my JSP page to a Spring Controller. After populating my array with the necessary data in the JSP, I initiate an AJAX request:
var ajaxRequest;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.open('POST', 'saveRecompensas.action');
ajaxRequest.send('array='+array);
Upon reaching the Controller:
@RequestMapping ("/proyecto/saveRecompensas")
public String saveRecompensas(@RequestParam ("array") String[] array, HttpSession session){
//public String saveRecompensas(){
System.out.println(Method saveRecompensas called");
return null;
}
The presence of two method signatures is intriguing. When omitting the @RequestParam ("array") String[] array, the method executes as expected. However, when including the RequestParam, the method fails to execute.
Am I sending the array correctly from the JSP to the Controller? Any guidance would be greatly appreciated. Thank you.