jsp 两个页面之间传参

wenwen1 发布于 2012/09/06 22:21
阅读 3K+
收藏 0

我的MyJsp.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" contentType="text/html;charset=UTF-8" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<%@ page session="true" %>
<!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=UTF-8">
<title>项目计划</title>
    <style type="text/css">
        label{
            width:100px;
            display:block;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/css/demo.css">
    <script type="text/javascript" src="../../jquery/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../../jquery/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../jquery/locale/easyui-lang-zh_CN.js"></script>
    <script>
//--------------------------验证是否为空 ------------------------------------------   
     $(document).ready(function(){
    $("#Setup_DATE").datebox({
    formatter:formatD
     });
  })
  function formatD(date){
   return date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay();
  }
 //------------------------------结束 -----------------------------
</script>
    <script type="text/javascript">
//--------------------------验证是否为空 ------------------------------------------   
    function doCheck(){
     if(form1.Project_ID.value==""){
      alert("请输入项目性质");
      form1.Project_ID.focus();
      return false;
     }
     else if(form1.Project_NAME.value==""){
      alert("请输入项目名称!");
      form1.Project_NAME.focus();
      return false;   
    }
    else if(form1.Setup_DATE.value==""){
      alert("请输入开始时间!");
      form1.Setup_DATE.focus();
      return false;
    }
    else if(form1.Setup_BY.value==""){
      alert("请输入项目委托负责人!");
      form1.Setup_BY.focus();   
    }
    else{
      return true;
    }
  }
  //------------------------------结束 -----------------------------
</script>
</head>
<%String Project_NAME = request.getParameter("Project_NAME");
request.setCharacterEncoding("utf-8");//处理乱码
session.setAttribute("Project_NAME",Project_NAME);
%> 
<body>
  <div style="background:#fafafa;padding:10px;">
  <form id="xmmc" name="form1" method="post" action="proApplicationjbSub.jsp" onSubmit="return doCheck()">
  <fieldset>
   <legend>项目基本信息(带*号为必填项)</legend>
    <table>
      <tr><td><label for="Project_    ID">项目性质*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="Project_ID" ></input></td>
           <td align="right"><label for="Project_NAME">项目名称*:</label></td>
           <td><input class="easyui-validatebox" width="300px" type="text" name="Project_NAME" ></input></td></tr>
       <tr><td><label for="Setup_DATE">项目开始时间*:</label></td>
           <td><input class="easyui-datebox" type="text" id="Setup_DATE" name="Setup_DATE" ></input></td>
           <td align="right"><label for="Setup_BY">项目委托单位法人代表/负责人*:</label></td>
           <td><input class="easyui-validatebox" type="text" id="Setup_BY" name="Setup_BY"></input></td></tr>
       <tr><td><label for="Specification">备注:</label></td>
           <td><textarea id="Specification" name="Specification"></textarea></td></tr>
    </table>
  </fieldset>
        <p align="center">
         <input type="submit" name="submit"  value="提交" />
         <input type="reset" name="reset"  value="重置"/> 
         <a href="../jsp/ptPeople.jsp" class="easyui-linkbutton">下一步</a>
        </p>       
     </form>
  </div>   
</body>
</html>
我的proApplicationjbSub.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<jsp:useBean id="systemRelated" class="net.gvsun.database.SystemRelated"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>proApplicationSub</title>

  </head>
 
  <body>
  <%
  request.setCharacterEncoding("utf-8");//处理乱码
  String Project_ID= request.getParameter("Project_ID");
  String Project_NAME = request.getParameter("Project_NAME");
  String Setup_DATE = request.getParameter("Setup_DATE");
  String Setup_BY = request.getParameter("Setup_BY");
  String Specification = request.getParameter("Specification");
  String sql = "insert into project(Project_ID,Project_NAME,Setup_DATE,Setup_BY,Specification) values ('"+Project_ID+"','"+Project_NAME+"','"+Setup_DATE+"','"+Setup_BY +"','"+Specification+"')";
  boolean bol = dbConn.Sql(sql);
  if(bol){
       out.println("添加成功!");
   }else{
       out.println("出错了,请重新操作!");
   }
  dbConn.releaseConn();//释放链接
  response.setHeader("Refresh","1; URL=proApplication.jsp?Project_NAME="+Project_NAME);//12秒后自动跳转页面
  %>   
  </body>
</html>
我的proApplication.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" contentType="text/html;charset=UTF-8" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<jsp:useBean id="systemRelated" class="net.gvsun.database.SystemRelated"/>
<%@ page session="true" %>
<!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=UTF-8">
<title>项目计划</title>
    <style type="text/css">
        label{
            width:100px;
            display:block;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/css/demo.css">
    <script type="text/javascript" src="../../jquery/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../../jquery/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../jquery/locale/easyui-lang-zh_CN.js"></script>
    <script>
//--------------------------验证是否为空 ------------------------------------------   
     $(document).ready(function(){
    $("#Setup_DATE").datebox({
    formatter:formatD
     });
  })
  function formatD(date){
   return date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay();
  }
 //------------------------------结束 -----------------------------
</script>
    <script type="text/javascript">
//--------------------------验证是否为空 ------------------------------------------   
    function doCheck(){
     if(form1.Project_ID.value==""){
      alert("请输入项目性质");
      form1.Project_ID.focus();
      return false;
     }
     else if(form1.Project_NAME.value==""){
      alert("请输入项目名称!");
      form1.Project_NAME.focus();
      return false;   
    }
    else if(form1.Setup_DATE.value==""){
      alert("请输入开始时间!");
      form1.Setup_DATE.focus();
      return false;
    }
    else if(form1.Setup_BY.value==""){
      alert("请输入项目委托负责人!");
      form1.Setup_BY.focus();   
    }
    else{
      return true;
    }
  }
  //------------------------------结束 -----------------------------
</script>
</head>
<%
request.setCharacterEncoding("utf-8");//处理乱码
response.setContentType("text/html;charset=utf-8");
String Project_NAME = request.getParameter("Project_NAME");
String sql = "select * from project where Project_NAME="+Project_NAME;
ResultSet rs = dbConn.doQuery(sql);
if(rs.next()){
 %>
<body>
  <div style="background:#fafafa;padding:10px;">
  <form id="xmmc" name="form1" method="post" action="proApplicationjbSub.jsp" onSubmit="return doCheck()">
  <fieldset>
   <legend>项目基本信息(带*号为必填项)</legend>
    <table>
      <tr><td><label for="Project_    ID">项目性质*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="Project_ID" value=<%=rs.getString("Project_ID") %>></input></td>
           <td align="right"><label for="Project_NAME">项目名称*:</label></td>
           <td><input class="easyui-validatebox" width="300px" type="text" name="Project_NAME" value=<%=rs.getString("Project_NAME") %>></input></td></tr>
       <tr><td><label for="Setup_DATE">项目开始时间*:</label></td>
           <td><input class="easyui-datebox" type="text" id="Setup_DATE" name="Setup_DATE" value=<%=rs.getString("Setup_DATE") %>></input></td>
           <td align="right"><label for="Setup_BY">项目委托单位法人代表/负责人*:</label></td>
           <td><input class="easyui-validatebox" type="text" id="Setup_BY" name="Setup_BY" value=<%=rs.getString("Setup_BY") %>></input></td></tr>
       <tr><td><label for="Specification">备注:</label></td>
           <td><textarea id="Specification" name="Specification"><%=rs.getString("Specification") %></textarea></td></tr>
    </table>
  </fieldset>
        <p align="center">
         <input type="submit" name="submit"  value="提交" />
         <input type="reset" name="reset"  value="重置"/> 
         <a href="../jsp/ptPeople.jsp" class="easyui-linkbutton">下一步</a>
        </p>       
     </form>
     <%
     }
     %>
    <%String datenow = systemRelated.getDateNow(); %>
     <form id="xm" name="form2" method="post" action="proApplicationSub.jsp">
<fieldset>
        <legend>项目基本信息(带*号为必填项)</legend>
          <table id="one">
           <tr><td><label for="xklym">学科领域码*:</label></td>
               <td><input class="easyui-validatebox" type="text"  name="xklym" required="true"></input></td>
               <td align="right"><label for="Ext_Name">学科领域*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Ext_Name" name="Ext_Name" required="true"></input></td></tr>
           <tr><td><label for="Project_Requirement">项目委托单位*:</label></td>
               <td><input class="easyui-validatebox" type="text" name="Project_Requirement" required="true"></input></td>
               <td align="right"><label for="Source_From">项目来源*:</label></td>
               <td><select  id="Source" name="Source_From"><option>----请选择一种项目来源----</option></select></td></tr>
           <tr><td><label for="post_code">邮编*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="post_code" name="post_code" required="true" ></input></td>
               <td align="right"><label for="End_Date">登记时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="Setup_Date"  disabled></input></tr>
           <tr><td><label for="xmyjwcsj">项目预计完成时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="xmyjwcsj" required="true" ></input></td>
               <td align="right"><label for="pzwcsj">批准完成时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="xmyjwcsj" required="true" ></input></td></tr>
           <tr><td><label for="sfwdhy">所服务的国民经济行业*:</label></td>
               <td><select  id="sfwd" name="sfwdhy"><option>------请选择一种经济行业-------</option></select></td>
               <td align="right"><label for="hdlx">活动类型*:</label></td>
               <td><select id="hdlx" name="hdlx"><option>------请选择一种活动类型-------</option></select></td></tr>
           <tr><td><label for="Desicion_Line">联系地址*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Desicion_Line" name="Desicion_Line" required="true" ></input></td>
               <td align="right"><label for="Project_Budget">合同经费*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Project_Budget" name="Project_Budget" required="true" ></input></td></tr>
           </table>
         </fieldset>
         </form>
          <form id="fzr" name="form2" method="post" action="proApplicationSub2.jsp">
          <fieldset>
          <legend>负责人(带*号为必填项)</legend>
           <table>
            <tr><td><label for="User_ID">负责人编号*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="user" name="User_ID" required="true" ></input></td>
                <td align="right"><label for="UserName">负责人*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="userName" name="userName" required="true" disabled></input></td></tr>
            <tr><td><label for="msn">院系所部中心*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="msn" name="msn" required="true" disabled></input></td>
                <td align="right"><label for="type">人员性质*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="type" name="type" required="true"  disabled></input></td></tr>
            <tr><td><label for="Role_ID">角色*:</label></td>
                <td><select id="role" name="Role_ID"><option>----请选择一种角色-----</option></select></td>
                <td align="right"><label for="grgzl">个人工作量比例*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="grgzl" name="grgzl" required="true" ></input></td></tr>
            <tr><td><label for="xb">性别*:</label></td>
                <td><select id="xb" name="xb"><option></option></select></td>
                <td align="right"><label for="mz">民族:</label></td>
                <td><input class="easyui-validatebox" type="text" id="mz" name="mz"></input></td></tr>
            <tr><td><label for="zgxl">最高学历:</label></td>
                <td><select id="zgxl" name="zgxl"><option>-----请选择最高学历-----</option></select></td>
                <td align="right"><label for="zgxw">最高学位:</label></td>
                <td><select id="zgxw" name="zgxw"><option>-----请选择最高学位-----</option></select></td></tr>
            <tr><td><label for="zw">专业职务*:</label></td>
                <td><select id="zw" name="zw"><option>------请选择职务------</option></select></td>
                <td align="right"><label for="phone">联系电话:</label></td>
                <td><input class="easyui-validatebox" type="text" id="phone" name="phone" required="true" ></input></td></tr>
             <tr><td><label for="Mob">手机:</label></td>
                <td><input class="easyui-validatebox" type="text" id="Mob" name="Mob" required="true" ></input></td>
                <td align="right"><label for="email">电子邮箱:</label></td>
                <td><input class="easyui-validatebox" type="text" id="email" name="email" required="true" ></input></td></tr>
            <tr><td><label for="csrq">出生日期:</label></td>
                <td><input class="easyui-datebox" type="text" id="csrq" name="csrq" required="true" ></input></td>
                <td align="right"><label for="bz">工作所属学院:</label></td>
                <td><input class="easyui-validatebox" type="text" id="bz" name="bz" required="true" disabled></input></td></tr>
            </table>
        </fieldset>
         <fieldset>
          <legend>项目其他信息(带*号为必填项)</legend>
           <table>
            <tr><td><label for="xmht">项目合同*:</label></td>
                <td><input class="easyui-validatebox" type="file" id="xmht" name="xmht" required="true" ></input></td></tr>
             <tr><td><label for="beiz">备注:</label></td>
                <td><textarea rows="5" cols="60"></textarea></td></tr>
            </table>
        </fieldset>

</form>
  </div>   
</body>
</html>
请问怎么从MyJsp.jsp中把Project_NAME传给proApplication.jsp啊?我是在proApplicationjbSub.jsp中response.setHeader来传,但是传不过,这是为什么啊?

加载中
0
loki_lan
loki_lan
好长,不想看
0
戴威
戴威
如果你放到代码标签里,大家会愿意看一些
0
侯林宏
侯林宏
好长。看到就烦
0
ZainZhou
ZainZhou
这一大堆,看见头都大了
0
一号男嘉宾
一号男嘉宾
这个太杀脑细胞。。
0
loking
loking

引用来自“梅公子”的答案

这个太杀脑细胞。。
+
返回顶部
顶部