我如何将数据从一个jsp页面发送到另一个jsp页面
问题描述:
我在从一个jsp页面向另一个jsp页面发送数据和id时遇到问题.实际上,我想将数据和ID从第一个jsp(a.jsp)页面发送到第二个jsp(b.jsp)页面.
I am getting the problem in sending data and id from one jsp page to another jsp page. Actualy i want to send data and id from first jsp(a.jsp) page to second jsp(b.jsp) page.
答
有三种方法可以将数据从一个JSP发送到另一个JSP
There are three ways to send data from one JSP to another
1.
String name="Hello";
request.setAttribute("Name",name);
通过另一个JSP访问:
From Another JSP Access by:
request.getAttribute("Name");//Hello
2.
String name="Hello";
session.setAttribute("Name",name);
通过另一个JSP访问:
From Another JSP Access by:
session.getAttribute("Name");//Hello
3.
String name="Hello";
localStorage.setItem("Name",name);
通过另一个JSP访问:
From Another JSP Access by:
localStorage.getItem("Name")//Hello