一、UserAction中获取到的ArrayList对象填充到UserForm中,jsp页面获取UserForm的初始值。
UserAction的部分代码:
复制代码 代码如下:
private ActionForward executeManageAction(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm)form;
ArrayList userlist = new ArrayList();
SessionFactory sf= new Configuration().configure().buildSessionFactory();
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
String sqlQuery="from User";
Query lQuery=session.createQuery(sqlQuery);
userlist=(ArrayList)lQuery.list();
tx.commit();
session.close();
userForm.setUserlist(userlist);
return mapping.findForward("main_user");
}
UsrForm的部分代码:
复制代码 代码如下:
private ArrayList userlist;
public ArrayList getUserlist(){
return userlist;
}
public void setUserlist(ArrayList userlist){
this.userlist=userlist;
}
JSP页面代码:
复制代码 代码如下:
<table id="id1" style="border-right: darkgreen 1px solid;border-top:darkgreen 1px solid;border-left: darkgreen 1px solid;width:100%;
border-bottom;darkgreen 1px solid;border-collapse:collapse" borderColor="darkgreen" cellSpacing="0" border="1">
<logic:notEmpty name="userForm" property="userlist">
<tr nowrap="nowrap">
<td style="width:80px;height:16px" nowrap><b>用户名</b></td>
<td style="width:80px;height:16px" nowrap><b>角色</b></td>
<td style="width:84px;height:16px" ><b>姓名</b></td>
<td style="width:88px;height:16px" ><b>电话</b></td>
<td style="width:73px;height:16px" ><b>电子邮件</b></td>
<td style="width:273px;height:16px" ><b>动作</b></td>
</tr>
<logic:iterate indexId="index" id="user" name="userForm" property="userlist">
<tr>
<td noWrap style="width:80px" ><bean:write name="user" property="username"/></td>
<td noWrap style="width:80px" ><bean:write name="user" property="role"/></td>
<td noWrap style="width:80px" ><bean:write name="user" property="name"/></td>
<td noWrap style="width:80px" ><bean:write name="user" property="tel"/></td>
<td noWrap style="width:80px" ><bean:write name="user" property="email"/></td>
<td nowrap sryle="width:273px" >
<a href="javascript:submitSid(document.fview,'<bean:write name="user" property="username"/>')">查看</a>
<font >||</font>
<a href="javascript:submitSid(document.fview,'<bean:write name="user" property="username"/>')">更新</a>
<font >||</font>
<a href="javascript:if (confirm('删除此用户么?')){ submitSid(document.fview,'<bean:write name="user" property="username"/>')}">删除</a>
</td></tr>
</logic:iterate>
</logic:notEmpty>
</table>
二、UserAction中获取到数据ArrayList对象后,把ArrayList对象存在request中,JSP页面在获取到ArrayList对象。
UserAction部分代码:
复制代码 代码如下:
private ActionForward executeManageAction(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm)form;
ArrayList userlist = new ArrayList();
SessionFactory sf= new Configuration().configure().buildSessionFactory();
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
String sqlQuery="from User";
Query lQuery=session.createQuery(sqlQuery);
userlist=(ArrayList)lQuery.list();
tx.commit();
session.close();
request.setAttribute("userlist", userlist);
return mapping.findForward("main_user");
}
JSP部分代码:
复制代码 代码如下:
<table id="id1" borderColor="darkgreen" cellSpacing="0" border="1">
<tr >
<td ><b>用户名</b></td>
<td ><b>角色</b></td>
<td ><b>姓名</b></td>
<td ><b>电话</b></td>
<td ><b>电子邮件</b></td>
<td ><b>动作</b></td>
</tr>
<logic:present name="userlist">
<logic:iterate indexId="index" id="user" name="userlist" >
<tr>
<td ><bean:write name="user" property="username"/></td>
<td ><bean:write name="user" property="role"/></td>
<td ><bean:write name="user" property="name"/></td>
<td ><bean:write name="user" property="tel"/></td>
<td ><bean:write name="user" property="email"/></td>
<td >
<a href="javascript:submitSid(document.fview,'<bean:write name="user" property="username"/>')">查看</a>
<font >||</font>
<a href="javascript:submitSid(document.fview,'<bean:write name="user" property="username"/>')">更新</a>
<font >||</font>
<a href="javascript:if (confirm('删除此用户么?')){ submitSid(document.fview,'<bean:write name="user" property="username"/>')}">删除</a>
</td></tr>
</logic:iterate>
</logic:present>
</table>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 黄乙玲1988-无稳定的爱心肝乱糟糟[日本东芝1M版][WAV+CUE]
- 群星《我们的歌第六季 第3期》[320K/MP3][70.68MB]
- 群星《我们的歌第六季 第3期》[FLAC/分轨][369.48MB]
- 群星《燃!沙排少女 影视原声带》[320K/MP3][175.61MB]
- 乱斗海盗瞎6胜卡组推荐一览 深暗领域乱斗海盗瞎卡组分享
- 炉石传说乱斗6胜卡组分享一览 深暗领域乱斗6胜卡组代码推荐
- 炉石传说乱斗本周卡组合集 乱斗模式卡组最新推荐
- 佟妍.2015-七窍玲珑心【万马旦】【WAV+CUE】
- 叶振棠陈晓慧.1986-龙的心·俘虏你(2006复黑限量版)【永恒】【WAV+CUE】
- 陈慧琳.1998-爱我不爱(国)【福茂】【WAV+CUE】
- 咪咕快游豪礼放送,百元京东卡、海量欢乐豆就在咪咕咪粉节!
- 双11百吋大屏焕新“热”,海信AI画质电视成最大赢家
- 海信电视E8N Ultra:真正的百吋,不止是大!
- 曾庆瑜1990-曾庆瑜历年精选[派森][WAV+CUE]
- 叶玉卿1999-深情之选[飞图][WAV+CUE]