Menu menu1 = new Menu();
menu1.setMenuName("menu");
menu1.setMenuUrl("url");
Menu menu2 = new Menu();
menu2.setMenuName("menu");
menu2.setMenuUrl("url");
List list = new ArrayList();
Menu subMenu1 = new Menu();
subMenu1.setMenuName("submenu");
subMenu1.setMenuUrl("url");
Menu subMenu2 = new Menu();
subMenu2.setMenuName("menu");
subMenu2.setMenuUrl("url");
list.add(subMenu1);
list.add(subMenu2);
map.put(menu1,list);
map.put(menu2,list);
request.setAttribute("menuMap",map);
在页面jsp中使用freemarker标签
<#list menuMap?keys as menuKeys>
<li>${menuKeys.name}</li>
<ul>
<#assign values_ = menuMap[menuKeys]>
<#list values_ as menu>
<li>
${menu.menuName }
</li>
</#list>
报错
Expression menuKey.memuName is undefined on line 17, column 51 in jsp/freemarker/menu.jsp.
The problematic instruction:
----------
==> ${menuKey.memuName } [on line 17, column 49 in jsp/freemarker/menu.jsp]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression menuKey.memuName is undefined on line 17, column 51 in jsp/freemarker/menu.jsp.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
在这里怎样遍历menuMap中value的值......
</ul>
</#list>