samedi 14 mars 2015

How to access map key/value pair contained in a ModelMap object from jsp Spring MVC

I have a ModelMap variable "model", the value object contained in the model map itself is a HashMap.


Controller code:



public @ResponseBody String func(ModelMap model)
{
HashMap<String, List<String> aMap = new HashMap<String, List<String>();
ArrayList<String> aList = new ArrayList<String>();
....// give aList some data
aMap.put("keystring", aList);
model.addAttribute("aMap", aMap);

String view = "test";
return view;
}


test.jsp code:



var data = '${aMap}';
// I know this gets the entire aMap including its key ("keystring")
// and the value (aList)


How do I access aMap's key ("keyString") and the value (aList) from test.jsp script part ? Any help will be appreciated.


Aucun commentaire:

Enregistrer un commentaire