I am currently working on an API controller. This controller should catch any unknown parameter and place it in the Map object. Now I use this code to catch all the parameters and put them in a Map
public String processGetRequest(final @RequestParam Map params)
Now the address I'm calling looks like this:
server/api.json?action=doSaveDeck&Card_IDS[]=1&Card_IDS[]=2&Card_IDS[]=3
Then I print out the parameters for debugging purposes using this piece of code:
if (logger.isDebugEnabled()) { for (Object objKey : params.keySet()) { logger.debug(objKey.toString() + ": " + params.get(objKey)); } }
Result:
10:43:01,224 DEBUG ApiRequests:79 - action: doSaveDeck 10:43:01,226 DEBUG ApiRequests:79 - Card_IDS[]: 1
But the expected result should look something like this:
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 at least tell me that Card_IDS is a String[] / List<String> and therefore should be running. I also tried manually changing the List<String> parameter, but this also does not work:
for (Object objKey : params.keySet()) { if(objKey.equals(NameConfiguration.PARAM_NAME_CARDIDS)){ //Never reaches this part List<String> ids = (List<String>)params.get(objKey); for(String id : ids){ logger.debug("Card: " + id); } } else { logger.debug(objKey + ": " + params.get(objKey)); } }
Can someone tell me how to get the Card_IDS array - It should be dynamically - from Map params using NameConfiguration.PARAM_NAME_CARDIDS ?
Jaap udejans
source share