views:

23

answers:

1
@RequestMapping(value = "/index", method = RequestMethod.GET)
public final String index(final ModelMap model)
{
      List myModels = ArrayList<MyModel>(getMyModels());
      model.addAttribute("mymodel", myModels);
      return "index";
}
  1. In Spring I put the myModels list into the ModelMap to be passed to the "index" view. How do I then access those MyModel objects from the JSTL code?

  2. Is it necessary for this controller method to be final and for the ModelMap parameter to be final?

+4  A: 
  1. By name, e.g <c:out value="${mymodel}"/>. Every model attribute you add to the ModelMap is made available as a JSP request-scoped attribute.

  2. "no" and "no", final is irrelevant here - did someone tell you otherwise?

skaffman
@peasoap: Spring doesn't care either way, it looks like an ill-advised stylistic choice by the author.
skaffman