HashMap怎么传过过值去?

guiyiqq 2011-01-10 10:18:43
jsp1
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" import="java.util.HashMap,com.inspur.cmd.*" %>
<%
HashMap has=new HashMap();
String st_no=request.getParameter("st_no");
String st_name=request.getParameter("st_name");
String st_sex=request.getParameter("st_sex");
String st_birthday=request.getParameter("st_birthday");
String st_class=request.getParameter("st_class");
has.put("st_no",st_no);
has.put("st_name",st_name);
has.put("st_sex",st_sex);
has.put("st_birthday",st_birthday);
has.put("st_class",st_class);
System.out.println("=="+st_no+st_name+st_sex+st_class+st_birthday);
if((st_no==null||"".equals(st_no))&&(st_name==null||"".equals(st_name))&&(st_sex==null||"".equals(st_sex))&&(st_birthday==null||"".equals(st_birthday))&&(st_class==null||"".equals(st_class))){
}else{
String act="search";
System.out.println("act=="+act);
has.put("actkey",act);
Controller.perform(has);

%>
<jsp:forward page="CA2002List.jsp"/>
<%
}
%>
<html>
<head>

<link rel="stylesheet" type="text/css" href="../css/green.contents.css">
<script language="javascript" src="../css/calendar.js"></script>
<title>学生检索(CA2001)</title>
</head>

<body leftMargin="0" topMargin="0" rightMargin="0" marginwidth="0" marginheight="0">
<form id="CA2001Search">

<table class="outside" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr id="outside_blk_title">
<td class="side_margin"></td>
<td class="title">
<table width="100%">
<tr>
<td class="formtitle">
学生检索
</td>
<td class="formid">
CA2001
</td>
</tr>
</table>
</td>
<td class="side_margin"></td>
</tr>
<tr id="outside_blk_contents">
<td class="side_margin"></td>
<td>
<table class="outline" cellspacing="0" cellpadding="0" width="100%" border="1">
<tr id="outline_blk_detail" class="sheet1">
<td>
<table class="outline"cellpadding="3">
<colgroup>
<col width="15%"/>
<col width="25%"/>
<col width="10%"/>
<col width="15%"/>
<col width="35%"/>
</colgroup>
<tr>
<td class="caption">学号</td>
<td >
<input name="st_no" type="text" class="input_left" size="10" maxlength="6">
<font color="red" size="-1">* 半角英数,最长6位</font>
</td>
<td> </td>
<td class="caption" ><span id="CA2001Search_torihikisaki_cd" >性别</span></td>
<td>
<input name="st_sex" value="1" type="radio">男
<input name="st_sex" value="2" type="radio">女
<input name="st_sex" value="0" type="radio" checked>全部
</td>
</tr>
<tr>
<td class="caption">姓名</td>
<td>
<input name="st_name" type="text" class="input_left" size="15" maxlength="15">
<font color="red" size="-1">* 最长15位</font>
</td>
<td> </td>
<td class="caption">生日</td>
<td >
<input name="st_birthday" type="text" class="input_left" size="15">
<font color="red" size="-1">* 格式:YYYY/MM/DD</font>
</td>
</tr>
<tr>
<td class="caption">班级</td>
<td>
<select id="st_class" name="st_class">
<option value="0" selected></option>
<option value="1">计算机1班</option>
<option value="2">计算机2班</option>
<option value="3">计算机3班</option>
<option value="4">计算机4班</option>
</select>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr id="outline_blk_dummy">
<td></td>
</tr>
<tr id="outline_blk_btn">
<td>
<table width="100%">
<tr>
<td width="20%" class="td_center"> </td>
<td width="20%" class="td_center">
<input
id="clear"
onClick="toClear()"
value="清除"
type="button"
onMouseOver="this.className='button_on'"
onMouseOut="this.className='button_off'"
class="button_off"></td>
<td width="20%" class="td_center"> </td>
<td width="20%" class="td_center">
<input
id="kigyoSearch"
onClick="toSearch()"
value="检索"
type="button"
onMouseOver="this.className='button_on'"
onMouseOut="this.className='button_off'"
class="button_off"></td>
<td width="20%" class="td_center"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>

<script language="javascript">
<!--
function toClear(){
document.forms[0].st_no.value="";
document.forms[0].st_sex.value="0";
document.forms[0].st_name.value="";
document.forms[0].st_birthday.value="";
document.forms[0].st_class.value="0";
}
function toSearch(){

document.forms[0].submit();
}
-->
</script>
</body>
</html>

[code=Java] try {
PreparedStatement psmt=Connect.conn.prepareStatement(sql);
ResultSet res=psmt.executeQuery();
has.put("reskey1", res);/code]

第一个jsp页面传值到dao.java中执行查询后有结果,获取查询结果后想传到另一个jsp页面去,也是用hash接收,为什么在另一个页面获取到得是空值?请指教
...全文
139 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanxmxj 2011-01-12
  • 打赏
  • 举报
回复
Controller.perform(has);

这个是执行什么

还有你的页面少个div开始符号 还是你少贴了?
shanxmxj 2011-01-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 guiyiqq 的回复:]
传过去了,可是第一个jsp页面怎么执行了两次?
[/Quote]
传过去了 有值么??
什么执行了2次?
guiyiqq 2011-01-12
  • 打赏
  • 举报
回复
request或者session吧
guiyiqq 2011-01-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 shanxmxj 的回复:]

JScript code
Controller.perform(has);

这个是执行什么

还有你的页面少个div开始符号 还是你少贴了?
[/Quote]
那个是命令工厂里面的函数。先执行一次能传过去值的,然后马上执行一次全是空值的,两次是一块执行的
guiyiqq 2011-01-10
  • 打赏
  • 举报
回复
传过去了,可是第一个jsp页面怎么执行了两次?
gsmlovewxj 2011-01-10
  • 打赏
  • 举报
回复
放到session当中就可以啊
guiyiqq 2011-01-10
  • 打赏
  • 举报
回复
没有保存,我是用命令工厂做的
happyfmy 2011-01-10
  • 打赏
  • 举报
回复
你把这个has保存在哪里了 request或者session?
没有的话 页面跳转 当然就没有了

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧