list - Spring MVC + RequestParam as Map + get URL array parameters not working -


i'm working on api controller. controller should able catch - unknown - parameter , put in map object. i'm using code catch parameters , put them in map

public string processgetrequest(final @requestparam map params) 

now url call follows:

server/api.json?action=dosavedeck&card_ids[]=1&card_ids[]=2&card_ids[]=3 

then print out parameters, debugging purposes, piece of code:

if (logger.isdebugenabled()) {     (object objkey : params.keyset()) {         logger.debug(objkey.tostring() + ": " + params.get(objkey));     } } 

the result of is:

10:43:01,224 debug apirequests:79 - action: dosavedeck 10:43:01,226 debug apirequests:79 - card_ids[]: 1 

but expected result should like:

10:43:xx debug apirequests:79 - action: dosavedeck 10:43:xx debug apirequests:79 - card_ids[]: 1 10:43:xx debug apirequests:79 - card_ids[]: 2 10:43:xx debug apirequests:79 - card_ids[]: 3 

or atleast tell me card_ids string[] / list<string> , therefore should casted. tried casting parameter list<string> manually not work either:

for (object objkey : params.keyset()) {     if(objkey.equals(nameconfiguration.param_name_cardids)){ //never reaches part         list<string> ids = (list<string>)params.get(objkey);           for(string id : ids){             logger.debug("card: " + id);         }     } else {         logger.debug(objkey + ": " + params.get(objkey));     } } 

could tell me how array card_ids - it must dynamically - map params using nameconfiguration.param_name_cardids?

when request map annotated @requestparam spring creates map containing request parameter name/value pairs. if there 2 pairs same name, 1 can in map. it's map<string, string>

you can access all parameters through multivaluemap:

public string processgetrequest(@requestparam multivaluemap parameters) { 

this map map<string, list<string>>. parameters same name in same list.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -