jsp,mysql - 将两个主键传递给另一个.jsp页面

时间:2016-03-04 21:10:31

标签: java mysql jsp servlets

我在传递2主键方面遇到了麻烦。此page1.jsp获取用户的会话ID,因此它只显示对他来说是陌生的。这是代码

<select id="e1" required="required" style="width:100%" name="phase_id">
<option value="">Select...</option>
<%
try { 
Statement stmt = con.createStatement();

ResultSet result = stmt.executeQuery("select d.phase_name, c.phase_id, a.id, c.p_id, a.empuser, b.employee_fname, b.employee_lname, c.p_name from logs_pms_t_project c join logs_r_employee b on c.employee_id=b.employee_id join logs_r_user a on a.empuser=b.employee_id join logs_pms_r_phase d on c.phase_id=d.phase_id where a.id="+session.getAttribute("id")+"");
                                                  while(result.next())
                                                  {
                                                        out.println("<option value="+result.getString("c.phase_id")+" title="+result.getString("c.phase_id")+" >" +result.getString("p_name")+ "</option>");
                                                  }
                                                  //con.close();
                                              } catch (Exception ex) {
      out.println("<script>alert('An Exception Occurred');</script>");
  }
              %>
    </select>

当用户选择某些内容时,他将被转移到此page2.jsp

<%
     String phase_id=request.getParameter("phase_id");
     System.out.println(phase_id);
    int phaseid=Integer.parseInt(phase_id);

        System.out.println(phaseid);
    if(phaseid == 1)
    { %> <%
    String redirectURL = "t_project_planning.jsp";
    response.sendRedirect(redirectURL);%> <%
    }

    if(phaseid == 2)
    { %> <%
    String redirectURL = "t_project_execution.jsp";
    response.sendRedirect(redirectURL);%> <%
    }

    if(phaseid == 3)
    { %> <%
    String redirectURL = "t_project_control.jsp";
    response.sendRedirect(redirectURL);%> <%
    }

    if(phaseid == 4)
    { %> <%
    String redirectURL = "t_project_close.jsp";
    response.sendRedirect(redirectURL);%> <%
    }

    %>

现在这是我的麻烦。在我的page3.jsp我有一个表单,我想不出如何将表单关联到在page1.jsp中选择的表中选择的项目上。 page3.jsp中的表单在page1.jsp上的表单中有一个外键。我想我在page2.jsp迷路了。

0 个答案:

没有答案
相关问题