Is it possible to have the value of a hidden input field as an array and then have it passed to the Spring MVC controller?
function foo(){
var myArray = new Array();
myArray[0] = "Hello";
myArray[1] = "World!";
document.getElementById("hiddenInp").value=myArray;
}
And then in the controller do something like
@RequestMapping ...
public String test(HttpServletRequest request)
{
String[] myArray = request.getParameter("hiddenInp");
// Assuming that the name of the hidden input field is also hiddenInp
System.out.println(myArray[0] + myArray[1]);
...
}
How about if I am working with an associative array? Where the indices are string rather than int
myArray["A"] = "Hello";
. I know that works because I've triedalert(myArray["A"])
and it gives me the pop-up box with "Hello". – Maurinemaurisevar myArray = { 'A' : 'Hello' };
. – Vagus