NutzCN Logo
问答 beetl 输出map value 多个对象的问题
发布于 2984天前 作者 CHQ 4488 次浏览 复制 上一个帖子 下一个帖子
标签: beetl
	@At("/corpus")
	@Ok("beetl:corpus.html")
	@Filters
    public Object corpus(HttpServletRequest req){
		Menu menu = menuService.fetch("corpus");
		right(req);
		req.setAttribute("menu",menu); 
		
		List<Author> st = authorService.query();
		NutMap nutMap = new NutMap();
		for(Author author:st){
			System.out.println("姓名:" + author.getName());
			String str = PinyinUtils.getHeadChar(author.getName());
			nutMap.addv(str, author);
		}
		System.out.println("nutMap:" + nutMap);
		return nutMap;
    }
	
    <%
	directive dynamic obj;
	%>
    <% for(o in obj){ %>
    	<div class="scholars_main" id="${o.key}">
			<h1 class="icolor">${o.key}</h1>
			<ul class="filter_list" alt="sss">
				
				${o.value.name} 
				
			</ul>
		</div>
    <% } %>
map数据结构
nutMap:{z=[/*com.yunou.bean.Author@37884aa7*/{"id":"5072e7576a764ec4b805b867e560690d","name":"张三","atrurl":"/upload/image/20160920/rcasp8da40i63oh0fqffob6fm9.jpg","info":"","createTime":"2016-09-20 18:40:08","updateTime":"2016-09-20 18:40:08"}, /*com.yunou.bean.Author@70628137*/{"id":"69cda3ed48c240ff825d77f314d9f941","name":"长城","atrurl":"","info":"","createTime":"2016-09-24 15:53:55","updateTime":"2016-09-24 15:53:55"}], c=/*com.yunou.bean.Author@4f5641c0*/{"id":"a5fe1ec9d61d420b8a6264bce1d0e9e0","name":"传奇","atrurl":"","info":"","createTime":"2016-09-24 15:54:01","updateTime":"2016-09-24 15:54:01"}, a=[/*com.yunou.bean.Author@6fd2e2eb*/{"id":"c84a66148d804fc2aa189fc7b4d53c59","name":"阿卡丽","atrurl":"","info":"","createTime":"2016-09-24 15:53:44","updateTime":"2016-09-24 15:53:44"}, /*com.yunou.bean.Author@1a7a40c4*/{"id":"ee9bd1efe3ee4a1d8850acb4a8541c96","name":"阿三","atrurl":"","info":"","createTime":"2016-09-24 15:53:50","updateTime":"2016-09-24 15:53:50"}], l=/*com.yunou.bean.Author@7e751185*/{"id":"e3f07bed26b34a6597ef2a939ee2f781","name":"李四","atrurl":"/upload/image/20160920/tt7e1rq9lujmtpb6ohcarq17hp.png","info":"","createTime":"2016-09-20 18:34:57","updateTime":"2016-09-20 18:34:57"}}

想要获取 ${o.value.name} 的值

4 回复

用list不好吗

哦,事实上你只是要知道beetl如何获取map的keyset

for  (key in @obj.keySet())
添加回复
请先登陆
回到顶部