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

主頁(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)與本站無(wú)關(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)民參考!
  • 推薦文章
    主站蜘蛛池模板: 蒙山县| 永康市| 菏泽市| 白沙| 利津县| 黑龙江省| 磐安县| 公安县| 喀什市| 禄劝| 德江县| 虹口区| 汉源县| 高平市| 德阳市| 托里县| 通江县| 登封市| 鄂温| 于都县| 陇南市| 宜良县| 磐石市| 崇明县| 淮滨县| 隆林| 遂宁市| 达孜县| 田林县| 友谊县| 汶上县| 当涂县| 清远市| 嘉祥县| 遵义市| 莎车县| 涟水县| 柯坪县| 洛浦县| 鹤庆县| 海原县|