Matriz de entrada oculta de Javascript
¿Es posible tener el valor de un campo de entrada oculto como una matriz y luego pasarlo al controlador Spring MVC?
function foo(){
var myArray = new Array();
myArray[0] = "Hello";
myArray[1] = "World!";
document.getElementById("hiddenInp").value=myArray;
}
Y luego en el controlador hacer algo como
@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]);
...
}
¿Qué tal si estoy trabajando con una matriz asociativa? Donde los índices son cadena en lugar de int.