[英](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";
}
In Spring I put the myModels
list into the ModelMap
to be passed to the "index" view. 在Spring中,我将myModels
列表放入ModelMap
以传递给“index”视图。 How do I then access those MyModel
objects from the JSTL code? 然后,我如何从JSTL代码访问这些MyModel
对象?
Is it necessary for this controller method to be final
and for the ModelMap
parameter to be final
? 这个控制器方法是否必须是final
并且ModelMap
参数是final
?
By name, eg <c:out value="${mymodel}"/>
. 按名称,例如<c:out value="${mymodel}"/>
。 Every model attribute you add to the ModelMap
is made available as a JSP request-scoped attribute. 您添加到ModelMap
每个模型属性都可用作JSP请求范围的属性。
"no" and "no", final
is irrelevant here - did someone tell you otherwise? “不”和“不”, final
在这里无关紧要 - 有人告诉你了吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.