sos:JSP页面之间参数的传递
a.jsp上有连接 <a href= "b.jsp "> ,其中a.jsp上有自定义类和数组,怎么将这类和数组从a.jsp点击时传递到b.jsp上呢?
------解决方案--------------------A 页面里request.setAttribute( "someString ",Object obj), 在B里 request.getAttribute( "someString ") 或者 <a href= "b.jsp?array=你定义的数组名称 "> ,在B里request.getParameter( "array ")
------解决方案--------------------可以保存到Session里面,然后在b.jsp里去取想要的值.
a.jsp
============
<%@ page language= "java " contentType= "text/html; charset=ISO-8859-1 "
pageEncoding= "ISO-8859-1 "%>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=ISO-8859-1 ">
<title> Insert title here </title>
<script type= "text/javascript ">
var value=document.getElementById( "name ");
</script>
</head>
<body>
<%
String userName= "Test name ";
session.putValue( "userName ",userName);
%>
<h1> This is a.jsp </h1>
<a href= "b.jsp "> b.jsp </a>
</body>
</html>
------------------------------
b.jsp
====================================
<%@ page language= "java " contentType= "text/html; charset=gbk "
pageEncoding= "gbk "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gbk ">
<title> Insert title here </title>
<script type= "text/javascript ">
String userName=Session.getValue( "userName ");
</script>
</head>
<body>
<h1> This is b.jsp </h1>
<%
String name=(String)session.getValue( "userName ");
%>
a.jsp中的 userName的值就是: <%=name %>
</body>
</html>