JSP頁面中iframe用法樣本__JSP

來源:互聯網
上載者:User

JSP頁面中iframe用法樣本:

首先,在JSP頁面中要包含另一頁面的位置添加如下代碼:

<tr widht="100%" bgcolor="#426199" class="text-01">
      <td bgcolor="#FBFBEE" width="100%">
       <iframe id="showfrm" name="showfrm" src="" width="100%" height="260" border=0 frameborder=auto marginheight=0 scrolling="auto"></iframe>
      </td>
     </tr>

然後再JavaScript中增加函數,如:

function shezhi(detail_code,detail_name,detail_fenzhi){
  showfrm.location.href = "<%=contextpath%>/servlet/KhpjDetailSetServlet?flag=showfpl&detail_code=" + detail_code+"&detail_name="+detail_name+"&detail_fenzhi="+detail_fenzhi;
 }

其次在KhpjDetailSetServlet中增加如下代碼:

if(flag.equals("showfpl"))
  {
   String detail_code = request.getParameter("detail_code");
   String detail_name = request.getParameter("detail_name");
   String detail_fenzhi = request.getParameter("detail_fenzhi");
   List list_shezhi = new ArrayList();
   Connection conn = null;
   Statement stmt = null;
   ResultSet rs = null;
   String sql ="SELECT B.CODE_NAME,A.FZ_TYPE,A.ZB_FZ FROM T_C_M_ZHZB_DETAIL A LEFT JOIN T_B_C_CODE_DIRECTORY B ON A.ZB_CODE=B.BASE_CODE WHERE A.ZB_CODE='"+detail_code+"'";
   try {
    conn = DBUtil.getConnection();                                               
    if(conn==null)
     throw new SQLException("資料庫忙,串連出錯,請重新串連!");
    stmt = conn.createStatement();
    rs=stmt.executeQuery(sql);
    while(rs.next())
    {
     DetailShezhiVo dshezhi = new DetailShezhiVo();
     dshezhi.setDetail_name(rs.getString(1));
     dshezhi.setFz_type(rs.getString(2));
     dshezhi.setFz_shezhi(rs.getString(3));
     list_shezhi.add(dshezhi);
    }
    
   } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
   request.setAttribute("detail_name", detail_name);
   request.setAttribute("detail_fenzhi", detail_fenzhi);
   request.setAttribute("list_shezhi", list_shezhi);
   dist="/pptf/khpj/KhpjDetailShezhi.jsp";                                          //String dist 是一個控制頁面跳轉路徑的字串
  }
  
  
  System.out.println("--------1---------");
  list_zhzb = query_zhzb();
  System.out.println("--------2---------");
  request.setAttribute("list_zhzb", list_zhzb);
  request.setAttribute("zhzb", zhzb);
  request.setAttribute("list_detail", list_detail);
  forward(request, response, dist);                                        //跳轉方式是公司內部包中寫的方式
 }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.