I am trying to pass a Javascript array from JSP to My controller class -
JSP -
var myArray = [];
myArray .push("OU=Software,DC=example,DC=com,");
myArray .push("OU=IT,DC=example,DC=com,");
$("#ADOus").attr("action","${ctx}/ADSetting?myOUsArray ="+ myArray );
$("#ADOus").submit();
Controller -
@RequestMapping(value = { "/ADSetting" }, method=RequestMethod.POST)
public String configureOUs(HttpServletRequest request,@RequestParam("myOUsArray ") String[] myOUsArray ){
logger.info("myOUsArray.length "+myOUsArray.length);
return "";
}
The problem is length received is 6 rather than 2. I suppose all the comma separated values are been considered as individual values to array. How to resolve this issue, i mean how can the java script array with comma and spaces can be received in my controller class.