永发信息网

struts2 标签 怎样取出iterator的一行数据

答案:2  悬赏:20  手机版
解决时间 2021-02-06 19:45
  • 提问者网友:wodetian
  • 2021-02-06 09:11
<s:iterator value="ptvList" var="item" status="st">
<td><s:property value="ptvList.get(#st.index).id.name" /></td>
这样可以打印出数据
<s:if test='%{<s:property value="ptvList.get(#st.index)" /> != null}'>
这样却报空

请大神帮忙!!!
最佳答案
  • 五星知识达人网友:刀戟声无边
  • 2021-02-06 09:38
struts2的iterator标签有begin和end属性

<tag>
<description><![CDATA[Iterate over a iterable value]]></description>
<name>iterator</name>
<tag-class>org.apache.struts2.views.jsp.IteratorTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<description><![CDATA[if specified the iteration will start on that index]]></description>
<name>begin</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[if specified the iteration will end on that index(inclusive)]]></description>
<name>end</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[Deprecated. Use 'var' instead]]></description>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[If specified, an instanceof IteratorStatus will be pushed into stack upon each iteration]]></description>
<name>status</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[if specified the iteration index will be increased by this value on each iteration. It can be a negative value, in which case 'begin' must be greater than 'end']]></description>
<name>step</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[the iteratable source to iterate over, else an the object itself will be put into a newly created List]]></description>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<description><![CDATA[Name used to reference the value pushed into the Value Stack]]></description>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<dynamic-attributes>false</dynamic-attributes>
</tag>
struts-tag.tld文件中的代码
<tag>
<name>iterator</name>
<tag-class>org.apache.struts2.views.jsp.IteratorTag</tag-class>
<body-content>JSP</body-content>
<description><![CDATA[Iterate over a iterable value]]></description>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description><![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description>
</attribute>
<attribute>
<name>status</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description><![CDATA[If specified, an instanceof IteratorStatus will be pushed into stack upon each iteration]]></description>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description><![CDATA[the iteratable source to iterate over, else an the object itself will be put into a newly created List]]></description>
</attribute>
</tag>
全部回答
  • 1楼网友:妄饮晩冬酒
  • 2021-02-06 10:46
好像有个属性 status ,值是当前遍历的这个集合的下标,可以用这个来作为的id,点击的时候,直接传当前点击的行的id,js里对他进行操作
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯