Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http request.getParameter( fieldname ) with List

I see that if an entry form in html has an input type = text ... I can read this text as a String with

request.getParameter( fieldname ).

But how can I read a List if the select is multiple?

I would like to set an ArrayList in a bean based on more than one parameter. Like this

List<String> values = request.getParameter( fieldsList );
like image 216
user3215484 Avatar asked Jun 27 '26 18:06

user3215484


1 Answers

I think you are looking for getParameterValues:

getParameterValues

String[] getParameterValues(String name) Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. If the parameter has a single value, the array has a length of 1.

Parameters: name - a String containing the name of the parameter whose value is requested Returns: an array of String objects containing the parameter's values See Also: getParameter(java.lang.String)

like image 152
meda Avatar answered Jun 30 '26 08:06

meda