Struts2 无法显示输出 [英] Struts2 not able to display output

查看:58
本文介绍了Struts2 无法显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 struts 2 标签显示列表数据.我有列表如下

I am trying to display the list data using struts 2 tags. I have list has follows

列表==>对象数组==>类对象

List ==> Array of Object ==> Object of class

我可以使用java代码从列表中获取值,如下所示

i can get the values from list using java code as follows

for(int i=0;i<redemptionDetails.size();i++)
        {
            Object[] Obj=(Object[])redemptionDetails.get(i);
            PointsRedemption ptredim=(PointsRedemption)Obj[0];
            System.out.println(ptredim.getCarrierId());             

        }

其中 redemptionDetails 是列表.

但是当我尝试使用 Struts2 标签显示时,我无法查看详细信息

but when I try to display using Struts2 tags I am not able to view details

我在下面尝试过使用 Struts2 标签

I have tried below using Struts2 tags

<s:iterator value="redemptionDetails" status="redemptionDetails">

                <s:set var="redemptionObject"
                    value="redemptionDetails.PointsRedemption"
                    scope="application"></s:set>

                <s:set var="productObject"
                    value="redemptionDetails.PointsProduct"
                    scope="application"></s:set>
                    <script>
                    //alert(<s:property value="#redemptionObject" />);
                    </script>
                <tr>
                    <td><s:property value="#application.redemptionObject.productCode" /></td>
                    <td><s:property value="#application.productObject.productCode" /></td>
                </tr>
            </s:iterator>

但我无法得到想要的结果.请帮忙

but I am not able to get the desire result. please help

推荐答案

要在 标签内显示 JSP 中的值,使用 top 关键字来获取当前值迭代器值.

To display values in JSP inside <s:iterator> tag use top keyword to get current iterator value.

<s:iterator value="redemptionDetails">
    <s:property value="top[0].carrierId"/>
</s:iterator>

这篇关于Struts2 无法显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆