用Struts+Hibernate时,在action里如何取得list集合? 可以放在request中或者session中的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 PropertyUtils.copyProperties(A, B);把B copy 到A中 先在此谢过解答,to: miaoliujun(傲龙) 你说的意思我明白,可是我不想在JSP页面中出现<%%>这个,不想有JAVA代码,我想让所有的数据都从Form里取得to: clcpxq(风卷残云) 我对PropertyUtils用法不太熟悉,你看我这样写可以吗? PropertyUtils.copyProperties(userList, iub.listAll()); 括号里面的userList是action里面定义的,iub.listAll()是bean里面的一个方法,返回值是List这样写的运行的时候报错的,java.lang.IllegalArgumentException: No destination bean specified 我自己用的时候,直接赋值就可以了,如:userAction.setUserList(iub.listAll())。不过要注意关联类的情况,具体参见Hibernate的参考 <logic:iterate id="userinfo" name="list" scope="request" type="valueobject.Userinfo"> <tr> <td><bean:write name="userinfo" property="user_name"></bean:write></td> <td><bean:write name="userinfo" property="user_phone"></bean:write></td> <td><bean:write name="userinfo" property="user_address"></bean:write></td> <td><bean:write name="userinfo" property="user_age"></bean:write></td> <td><bean:write name="userinfo" property="user_sex"></bean:write></td> </tr></logic:iterate>list中存的是Object ,所以,你把各个对象取出来之后要造型成为你的valueobject.Userinfo.这样才可以。----------------------------把需要造型的目标类,用你的,就可以了! 求解:使用ssh框架,为何调试时得不到画面上输入的值? 点上下排序问题..... 跪求孙鑫的那本《struts2深入详解》电子书 HTML的触发的事件 图像缩放怎么没有效果啊 NullPointerException几天都没解决的问题 关于java调用.net webservice 数据类型问题,请大家看看! java怎么调用DB2 的function?? ajax回调问题 eclipse2.1在redhat linux8(9)下的起动 Struts中文问题之写文件 关于hibernate的问题啊!!
把B copy 到A中
你说的意思我明白,可是我不想在JSP页面中出现<%%>这个,不想有JAVA代码,我想让所有的数据都从Form里取得to: clcpxq(风卷残云)
我对PropertyUtils用法不太熟悉,你看我这样写可以吗?
PropertyUtils.copyProperties(userList, iub.listAll());
括号里面的userList是action里面定义的,iub.listAll()是bean里面的一个方法,返回值是List
这样写的运行的时候报错的,
java.lang.IllegalArgumentException: No destination bean specified
<tr>
<td><bean:write name="userinfo" property="user_name"></bean:write></td>
<td><bean:write name="userinfo" property="user_phone"></bean:write></td>
<td><bean:write name="userinfo" property="user_address"></bean:write></td>
<td><bean:write name="userinfo" property="user_age"></bean:write></td>
<td><bean:write name="userinfo" property="user_sex"></bean:write></td>
</tr>
</logic:iterate>list中存的是Object ,所以,你把各个对象取出来之后要造型成为你的valueobject.Userinfo.
这样才可以。
----------------------------
把需要造型的目标类,用你的,就可以了!