Reputation: 20581
In servlet I get POST parameters where keys are not unique. Like this
id = 12, id = 13, id = 14
So I can't use getParameterMap()
to get this parameters (because HashMap contain only unique keys). What is the best way to solve this problem and get values from all non-unique parameters from POST query?
Thanks!
UPD. I cant edit request parameters (I retrieve this parameters from other app)
Upvotes: 6
Views: 4225
Reputation: 4581
The method getParameterValues() is especially usefull when there are multiple parameters with the same name in a request. The getParameterValues() method returns the value or values of the parameter paramName. The values are returned in the form of an array of strings. If the parameter paramName has mulitple values in the request, then each of those values is returned in the array.
public abstract interface ServletRequest
{
public abstract String[] getParameterValues(String paramString);
....
}
Upvotes: 9