本文介绍了如何在Struts 2中使用DisplayTag与嵌套列表和属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图显示一个列表。在这个列表中还有另一个我想要显示的列表。使用Struts,我的代码如下所示: < s:iterator value =lendingList>
< tr>
< td>< s:属性值=lendBy.matNumber/> < s:property
value =lendBy.firstName/> < s:属性值=lendBy.name/>< / td>
< td>< s:property value =date/>< / td>
< td>< s:iterator value =publication>
< / s:迭代器>< / td>
< td>< s:iterator value =publication>
< s:property value =title/>
< / s:迭代器>< / td>
< td>< s:property value =returnDate/>< / td>
< td>< s:property value =remindProcessStarted/>< / td>
新的DisplayTag表格如下所示:
< display:table id =lendingListname =lendingListpagesize =6
cellpadding =5px; CELLSPACING = 5像素;
style =margin-left:50px; margin-top:20px; requestURI =sort =list>
< display:column property =lendBy.matNumbertitle =Mat.-Nr。
sortable =true/>
< display:column property =lendBy.firstNametitle =Nachname
sortable =true/>
< display:column property =lendBy.nametitle =Vornamesortable =true/>
< display:column property =publication.isbntitle =Vornamesortable =true/>
< display:column property =publication.titletitle =Vornamesortable =true/>
< display:column property =returnDatetitle =Rückgabedatum
sortable =true/>
< / display:table>
我尝试使用 publication.isbn
,但不幸的是它不工作。我无法在文档中找到任何提示。
解决方案
问题是我不得不给出 uid
添加到表中,然后我可以像下面这样使用Struts 迭代器
访问属性:
< display:column media =htmltitle =Titelsortable =true>
< s:property value =title/>
< / s:iterator>
< / display:column>
I'm trying to display a list. Inside this list there is another list which I want to display. With Struts my code looked like this:
<s:iterator value="lendingList">
<tr>
<td><s:property value="lendBy.matNumber" /> <s:property
value="lendBy.firstName" /> <s:property value="lendBy.name" /></td>
<td><s:property value="date" /></td>
<td><s:iterator value="publication">
<s:property value="isbn" />
</s:iterator></td>
<td><s:iterator value="publication">
<s:property value="title" />
</s:iterator></td>
<td><s:property value="returnDate" /></td>
<td><s:property value="remindProcessStarted" /></td>
The new DisplayTag Table looks like this:
<display:table id="lendingList" name="lendingList" pagesize="6"
cellpadding="5px;" cellspacing="5px;"
style="margin-left:50px;margin-top:20px;" requestURI="" sort="list">
<display:column property="lendBy.matNumber" title="Mat.-Nr."
sortable="true" />
<display:column property="lendBy.firstName" title="Nachname"
sortable="true" />
<display:column property="lendBy.name" title="Vorname" sortable="true" />
<display:column property="publication.isbn" title="Vorname" sortable="true" />
<display:column property="publication.title" title="Vorname" sortable="true" />
<display:column property="returnDate" title="Rückgabedatum"
sortable="true" />
</display:table>
I tried to access the properties with publication.isbn
, but unfortunately it is not working. I couldn't find any hints in the documentation.
解决方案
The problem was that I had to give a uid
to the table, after that I can access the properties with a Struts iterator
like this:
<display:column media="html" title="Titel" sortable="true">
<s:iterator value="#attr.lendingList.publication">
<s:property value="title" />
</s:iterator>
</display:column>
这篇关于如何在Struts 2中使用DisplayTag与嵌套列表和属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!