Thursday, 22 August 2013

Spring Web MVC: How to retrieve model (passed as map) in a view?

Spring Web MVC: How to retrieve model (passed as map) in a view?

When using ModelandView constructor with two parameters - String viewName,
Map model - to pass multiple parameters to a view JSP, how do I then
retrieve them?
If they are retrieved like map values, then what is the map name?
Let say, my controller code has the following:
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("1", "one");
myModel.put("2", "two");
return new ModelAndView("view", myModel);
What do I need to put into JSP so "one" and "two" appear on the page?
I'm using Java EE 7, Spring 3.2.4, GlassFish 4 server

No comments:

Post a Comment