濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例

jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例

熱門標(biāo)簽:潤(rùn)滑油銷售電銷機(jī)器人 電話機(jī)器人需要使用網(wǎng)絡(luò)嗎 電銷機(jī)器人免培訓(xùn) 外呼系統(tǒng)使用方法 給地圖標(biāo)注得傭金 如何看懂地圖標(biāo)注點(diǎn) 海外圖書館地圖標(biāo)注點(diǎn) 南通通訊外呼系統(tǒng)產(chǎn)品介紹 自繪地圖標(biāo)注數(shù)據(jù)

一,在div中插入要顯示的數(shù)據(jù)!

1,以下是原網(wǎng)頁(yè)插入數(shù)據(jù)代碼:

div>
 ul class="list-content">
li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa./a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa./a>span>[06-29]/span>/li>
ul>
div>
div>
ul class="list-content">
li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
 li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa.../a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa/a>span>[06-29]/span>/li>
li>a href="">aaaaaaaaaaaaaaaaaaa.../a>span>[06-29]/span>/li>
ul>
/div>

2,在src中創(chuàng)建servlet類:

使用request.setAttribute發(fā)送數(shù)據(jù)

public static ArrayListString> list;
 static{
 list=new ArrayListString>();
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee"); 
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee"); 
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee"); 
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee"); 
   public static ArrayListString> listdc;
 static{
 listdc=new ArrayListString>();
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
 }
 public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  request.setCharacterEncoding("UTF-8");
  response.setContentType("text/html");
  ArrayListString>list=getData();
  
  request.setAttribute("new", list);
  request.setAttribute("dc", listdc);
  request.getRequestDispatcher("/page/default.jsp").forward(request, response);
 }

3,在需要插入數(shù)據(jù)的地方加入jsp腳本:

使用request.getAttribute接收數(shù)據(jù)

通過for循環(huán)打印數(shù)據(jù)

div>
     ul class="list-content">
     
      %
      ArrayListString> list =(ArrayListString>)request.getAttribute("new");
      if(list!=null)
       for(int i=0;ilist.size();i++){
      %>
       li>
      a href="" style=" rel="external nofollow" rel="external nofollow" width:644px">
        % out.print(list.get(i)); %>
        /a>span>
        [06-29]
        /span>
       /li>
      % }%>
     /ul>
    /div>
    div>
     ul class="list-content">
     %ArrayListString> listdc=(ArrayListString>)request.getAttribute("dc");
      if(listdc!=null)
      for(int i=0;ilistdc.size();i++){
     %>
     li>
     a href="" style=" rel="external nofollow" rel="external nofollow" width:644px">
     % out.print(listdc.get(i)); %>
     /a>span>
     [06-29]/span>
     /li>
     % } %>
     /ul>
    /div>

以上這篇jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • SpringMVC 向jsp頁(yè)面?zhèn)鬟f數(shù)據(jù)庫(kù)讀取到的值方法
  • jsp實(shí)現(xiàn)textarea中的文字保存換行空格存到數(shù)據(jù)庫(kù)的方法
  • Struts2.5 利用Ajax將json數(shù)據(jù)傳值到JSP的實(shí)例
  • JSP 自定義標(biāo)簽實(shí)現(xiàn)數(shù)據(jù)字典的實(shí)例
  • 讀取數(shù)據(jù)庫(kù)的數(shù)據(jù)并整合成3D餅圖在jsp中顯示詳解
  • springMVC如何將controller中數(shù)據(jù)傳遞到j(luò)sp頁(yè)面
  • jsp中EL表達(dá)式獲取數(shù)據(jù)
  • JSP數(shù)據(jù)交互實(shí)現(xiàn)過程解析

標(biāo)簽:南京 貸款邀約 廣州 黃石 樂山 大連 銅川 內(nèi)江

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例》,本文關(guān)鍵詞  jsp,使用,request,為,頁(yè)面,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    凌云县| 会东县| 孟州市| 苗栗市| 大埔区| 花莲县| 河曲县| 徐水县| 达孜县| 布拖县| 巴楚县| 吉隆县| 若尔盖县| 天全县| 克东县| 雅安市| 女性| 大洼县| 威海市| 哈密市| 穆棱市| 邵阳市| 定远县| 醴陵市| 大关县| 大宁县| 房产| 瑞安市| 昆明市| 福贡县| 易门县| 北海市| 华安县| 扎鲁特旗| 鹿邑县| 南汇区| 额敏县| 永州市| 霍城县| 闻喜县| 桐乡市|