校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > Action中ArrayList顯示到JSP頁面的具體實例

Action中ArrayList顯示到JSP頁面的具體實例

熱門標簽:地圖標注專業和非專業 福建電銷貓機器人收費 湖北地圖標注公司 外呼直播語音系統 山東ai外呼電銷機器人好用嗎 汝南縣地圖標注app 甘肅銷售電銷機器人公司 四川正規外呼系統軟件 智能電話機器人銷售話術

一、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>

標簽:白銀 吳忠 梅州 肇慶 黔東 昌都 臨沂 南充

巨人網絡通訊聲明:本文標題《Action中ArrayList顯示到JSP頁面的具體實例》,本文關鍵詞  Action,中,ArrayList,顯示,到,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Action中ArrayList顯示到JSP頁面的具體實例》相關的同類信息!
  • 本頁收集關于Action中ArrayList顯示到JSP頁面的具體實例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 波密县| 淮北市| 克山县| 沂源县| 临洮县| 新丰县| 温泉县| 金溪县| 隆尧县| 罗城| 江口县| 若羌县| 喀喇沁旗| 琼海市| 奉节县| 花莲市| 阳东县| 广州市| 墨脱县| 昆山市| 石楼县| 辽中县| 章丘市| 潜山县| 茌平县| 滕州市| 泸州市| 盐亭县| 清水河县| 清徐县| 高平市| 岢岚县| 当雄县| 苍山县| 土默特左旗| 汾西县| 南江县| 曲沃县| 凯里市| 晋城| 惠水县|