java 把数据放进String 数组 再把数组放进list再保存到session传到下一个jsp再读出来.给完整代码完整代码
展开全部
stringarray1.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>提交</title>
</head>
<body>
<%
String a[][] = {{"deco3942","123456","tom"},
{"tank123","382839","jhon"},
{"ppk1999","322992","jack"},
{"wecan38","s32919","pril"}};
List<String[]> list = new ArrayList<String[]>();
for(int i=0;i<a.length;i++){
list.add(a[i]);
}
//System.out.println("a="+a);
session.setAttribute("list",list);
%>
<h1>发送的数组为:</h1>
<form id="form" name="form" action="stringarray2.jsp" method="post">
<input type="text" value="<%=a[0][0] %>,<%=a[0][1] %>,<%=a[0][2] %>"><br>
<input type="text" value="<%=a[1][0] %>,<%=a[1][1] %>,<%=a[1][2] %>"><br>
<input type="text" value="<%=a[2][0] %>,<%=a[2][1] %>,<%=a[2][2] %>"><br>
<input type="text" value="<%=a[3][0] %>,<%=a[3][1] %>,<%=a[3][2] %>"><br>
<input type="submit" value="跳转">
</form>
</body>
</html>
stringarray2.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String b[][] = new String[4][];
List<String[]> list = (List<String[]>)session.getAttribute("list");
for(int i=0;i<b.length;i++){
b[i] = list.get(i);
}
//System.out.println("b="+b);
%>
<html>
<head>
<title>接收</title>
</head>
<body>
<h1>接收到的数组为:</h1>
<input type="text" value="<%=b[0][0] %>,<%=b[0][1] %>,<%=b[0][2] %>"><br>
<input type="text" value="<%=b[1][0] %>,<%=b[1][1] %>,<%=b[1][2] %>"><br>
<input type="text" value="<%=b[2][0] %>,<%=b[2][1] %>,<%=b[2][2] %>"><br>
<input type="text" value="<%=b[3][0] %>,<%=b[3][1] %>,<%=b[3][2] %>"><br>
</body>
</html>
展开全部
1.jsp
<%String[] arry1 = String[]{"deco3942","123456","tom"};%>
<%String[] arry2 = String[]{"tank123","382839","jhon"};%>
...
<%List<String[]> list = new LinkedList<String[]>();%>
<%list.add(arry1);%>
<%list.add(arry2);%>
<%session.setAttribute("arrlist",list);%>
...(2.jsp)
<%List<String[]> list = (List<String[]>)session.getAttribute("arrlist");%>
...
session为jsp内置对象可以直接使用,
大概就是这个样子,后面不用写了吧
<%String[] arry1 = String[]{"deco3942","123456","tom"};%>
<%String[] arry2 = String[]{"tank123","382839","jhon"};%>
...
<%List<String[]> list = new LinkedList<String[]>();%>
<%list.add(arry1);%>
<%list.add(arry2);%>
<%session.setAttribute("arrlist",list);%>
...(2.jsp)
<%List<String[]> list = (List<String[]>)session.getAttribute("arrlist");%>
...
session为jsp内置对象可以直接使用,
大概就是这个样子,后面不用写了吧
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询