org.springframework.ui.Model 如何显示List数据?


比如说:


 java


 List<Photo> list = new ArrayList<Photo>();
        if (jsonDataList != null) {
            for (String json : jsonDataList) {
                Photo photo = (Photo) JacksonUtil.jsonToBean(json, Photo.class);
                list.add(photo);
            }
        }

        model.addAttribute("photos", list);

然后直接使用EL表达式显示数据就可以了吗?

spring-mvc

小贝尔、喵 10 years, 1 month ago

是的啊,可以直接通过jsp的标签展现:


 <c:forEach items="${talkList}" var="talk">
        <h3 id="${talk.title}">${talk.title}
        <span class="label"><a
                href="/crm/talk/edit.inner?talkId=${talk.id}">修改</a></span>
                            <span class="label"><a href="javascript:;"
                                                   onclick="showDelete(${talk.id});"
                                                   data-trigger="confirm">删除</a></span></h3>
        ${talk.content}
    </c:forEach>

Mr.Hao answered 10 years, 1 month ago

Your Answer