If a html form has multiple inputs with the same name, a Servlet will understand it as Array:
Form:
<form>
User 1:<input name="user" />
User 2:<input name="user" />
User 3:<input name="user" />
<input type="submit" />
</form>
Servlet:
String[] user = request.getParameterValues("user");
But if I use jQuery to make an ajax call, and send a array as a parameter, it adds "[]" in the property name
Javascript:
$.ajax({
...
data:{
user: ["value1", "value2", "value3"]
}
});
Inspecting the header of the request, the data were sent:
Form Data
user[]=value1&user[]=value2&user[]=value3
I know I can add [] at the end of parameter of getParameterValues, but I prefer that jQuery does not send the []
How can I do this?