是否可以将隐藏输入字段的值作为数组传递给 Spring MVC 控制器?
function foo(){
var myArray = new Array();
myArray[0] = "Hello";
myArray[1] = "World!";
document.getElementById("hiddenInp").value=myArray;
}
然后在控制器中做类似的事情
@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]);
...
}
如果我正在使用关联数组呢?索引是字符串而不是 int