Javascript Hidden Input Array
Czy możliwe jest posiadanie wartości ukrytego pola wejściowego jako tablicy, a następnie przekazanie jej do kontrolera Spring MVC?
function foo(){
var myArray = new Array();
myArray[0] = "Hello";
myArray[1] = "World!";
document.getElementById("hiddenInp").value=myArray;
}
A potem w kontrolerze coś takiego
@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]);
...
}
A jeśli pracuję z tablicą asocjacyjną? Gdzie indeksy są raczej ciągiem niż int