Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > jsp入门教程

jsp使用request为页面添加静态数据的实例

来源:中文源码网    浏览:383 次    日期:2024-04-26 01:48:19
【下载文档:  jsp使用request为页面添加静态数据的实例.txt 】


jsp 使用request为页面添加静态数据的实例
一,在div中插入要显示的数据!
1,以下是原网页插入数据代码:


  • aaaaaaaaaaaaaaaaaaa[06-29]

  • aaaaaaaaaaaaaaaaaaa[06-29]

  • aaaaaaaaaaaaaaaaaaa.[06-29]

  • aaaaaaaaaaaaaaaaaaa[06-29]

  • aaaaaaaaaaaaaaaaaaa.[06-29]




    • 2,在src中创建servlet类:
      使用request.setAttribute发送数据
      public static ArrayList list;
      static{
      list=new ArrayList();
      listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
      listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
      listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
      listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
      listdc.add("dcrewrwe3eeeeeeeeeeeeeeeee");
         public static ArrayList listdc;
      static{
      listdc=new ArrayList();
      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");
      ArrayListlist=getData();
      request.setAttribute("new", list);
      request.setAttribute("dc", listdc);
      request.getRequestDispatcher("/page/default.jsp").forward(request, response);
      }
      3,在需要插入数据的地方加入jsp脚本:
      使用request.getAttribute接收数据
      通过for循环打印数据






      以上这篇jsp 使用request为页面添加静态数据的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持中文源码网。

相关内容