读书人

struts的s:iterator标签能获取到List的

发布时间: 2013-03-26 09:54:34 作者: rapoo

struts的s:iterator标签能获取到List的内容不能获取ArrayList的内容?麻烦大家过来看下 先谢谢了
可能大家在Javaee板块中也看到这个帖子 我在此重新发布是为了能让更多的人帮我看看这个问题
http://topic.csdn.net/u/20120601/09/23813317-a2b4-4809-934a-34650ab25183.html?79161
以上是在javaee板块中的帖子
内容:

最近在弄SSH的东西时我发现我在Action中通过request(Map)向Action的结果页(result)传对象时发现,我能将一个直接通过Hibernate(this.getHibernateTemplate().find(..))返回的List<..>的对象传递给Action的结果页并能正确显示,但是我自己定义的一个工具类(由于通过Hibernate返回的List<..>有些许是外键(int类型)需要转化才能得到对应的描述即了解身份证号但我们需要的是姓名)所以我就写了这个工具类用以转化)存进ArrayList中用同一种方式却不能正常显示。
代码:
Action中的代码:

Java code
        Map request=(Map)ActionContext.getContext().get("request");        List<Orderlist> curorder=orderservice.findBycurord(Integer.parseInt(userids));          User us=user.findById(Integer.parseInt(userids));        List<Userdet> det=userdet.findU(Integer.parseInt(userids));        List<OrderListT> olt=new ArrayList<OrderListT>();   //存放工具类的集合        for(Orderlist ord:curorder){            OrderListT ordt=new OrderListT();   //工具类                        //转换开始            ordt.setId(ord.getId());            ordt.setNum(ord.getNum());            Netpoint net=netService.findbyId(ord.getSource());            ordt.setSource(net.getNetname());            net=netService.findbyId(ord.getDestin());            ordt.setDestin(net.getNetname());            ordt.setPrice(ord.getPrice());            ordt.setTypename("国内件");            Category cate=cateService.findid(ord.getClassname());            ordt.setClassname(cate.getClassname());            ordt.setUsername(ord.getUserid());            Orderstatus sta=orderstaService.findid(Integer.parseInt(ord.getStatus()));            ordt.setStatus(sta.getStatusname());            ordt.setBedate(ord.getBedate());            ordt.setEndate(ord.getEndate());                        //转化结束            olt.add(ordt);        //添加进ArrayList        }        request.put("curorder", curorder);  //发送到struts.xml文件中该Action指定的result页面


struts.xml中的代码: (这个应该没有错,对应的spring的配置也应该没有问题)

XML code
             <action name="userInfo" class="userInfoAction">            <result name="success">/personinfo.jsp</result>        </action>


personinfo.jsp中的代码: 用以接受从Action中传来的数据
HTML code
                <s:iterator value="#request.curorder" id="order">                <li><s:property value="#order.num" />                    <s:property value="#order.source" />                    <s:property value="#order.destin" />                    <s:property value="#order.status" />                    <s:property value="#order.bedate" />                    <s:property value="#order.endate" /></li>                </s:iterator>


麻烦各位给我分析下,在此再次谢谢哈!



[解决办法]
Netpoint net=netService.findbyId(ord.getSource());?代码不全不好说,然后是你把报错信息贴上,这是最起码的

[解决办法]
会不是是因为你从数据库那数据是用的session.load().你换成session.get()看行不行,
.load()有延迟机制,你跳转在jsp页面在执行Struts的那些get()方法 可能就拿不到对象的

读书人网 >Java Web开发

热点推荐