简体   繁体   中英

(Question about 'final' and) How do I access the list object contents of 'myModels' from the Spring ModelMap in JSTL?

@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 ?

  1. By name, eg <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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM