struts2 标签 怎样取出iterator的一行数据
<s:iteratorvalue="ptvList"var="item"status="st"><td><s:propertyvalue="ptvList.get(#st...
<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}'>
这样却报空
请大神帮忙!!! 展开
<td><s:property value="ptvList.get(#st.index).id.name" /></td>
这样可以打印出数据
<s:if test='%{<s:property value="ptvList.get(#st.index)" /> != null}'>
这样却报空
请大神帮忙!!! 展开
2个回答
2015-08-14 · 知道合伙人数码行家
关注
展开全部
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>
<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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你是每次遍历出来每一个对象然后取对象中的属性吗?你进行判断的目的是什么?
更多追问追答
追问
先取出每个list的ptv对象的属性 点击一行属性 将ptv对象传出去 不知道怎样获取ptv对象
追答
遍历出来的每一个都是一个ptv对象,存放到了item中了,
//获得name,是否加#号不确定
//获得id,是否加#号不确定
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询