Servlet. How to get parameters if their keys are not unique?

In the servlet, I get POST options where the keys are not unique. Like this

id = 12, id = 13, id = 14 

Therefore, I cannot use getParameterMap() to get these parameters (since the HashMap contains only unique keys). What is the best way to solve this problem and get values ​​from all unique parameters from a POST request?

Thanks!

UPD I cannot change the request parameters (I am extracting these parameters from another application)

+6
source share
1 answer

The getParameterValues ​​() method is especially useful if there are several parameters with the same name in the request. The getParameterValues ​​() method returns the value or values ​​of the paramName parameter. Values ​​are returned as an array of strings. If paramName has mulitple values ​​in the request, then each of these values ​​is returned in an array.

 public abstract interface ServletRequest { public abstract String[] getParameterValues(String paramString); .... 

}

+9
source

Source: https://habr.com/ru/post/908352/


All Articles