一个页面中有多个form要怎样处理

 我来答
yf...8@163.com
2017-04-03 · 超过186用户采纳过TA的回答
知道小有建树答主
回答量:596
采纳率:0%
帮助的人:89.3万
展开全部
可以的,直接创建多个form即可,形式就是“<form></form><form></form>”,此时每个form中的内容就是独立提交的部分。

举例:
<form id='modify1' name="modify1" method="post" enctype="multipart/form-data" action="${ctx}/report/rate_exchange.jsp" >
<table class="table_common" id="table1" cellspacing="1" cellpadding="0">
<tr class='title_tr' >
<td style="white-space: nowrap; text-align: center;" colspan="4">
匿名用户
2017-05-27
展开全部
首先是提交页面:三个表单(form1,form2,form3)
<form name="form1" method="post" action="checklogin.jsp" class="niceform">
<input name="qx" type="hidden" value="3">
<label for="textinput">帐号:</label>
<input type="text" id="textinput" name="uid" size="12" />
<br />
<label for="passwordinput">密码:</label>
<input type="password" id="passwordinput" name="pwd" size="12" />
<br />
<input name="" type="submit" value="提交">
<input type="reset" name="Submit2" value="重置" />
</form>
</div>
<div class=tagContent id=tagContent1>欢迎使用本系统,请先【登陆】或【注册】。
<form name="form2" method="post" action="checklogin.jsp" class="niceform">
<input name="qx" type="hidden" value="2">
<label for="textinput">帐号:</label>
<input type="text" id="textinput" name="uid" size="12" />
<br />
<label for="passwordinput">密码:</label>
<input type="password" id="passwordinput" name="pwd" size="12" />
<br />
<input name="Submit1" type="submit" id="Submit1" value="提交" />
<input type="reset" name="Submit2" value="重置" />
</form>
</div>
<div class=tagContent id=tagContent2>欢迎使用本系统,请先【登陆】然后进行管理。
<form name="form3" method="post" action="admin/checklogin.jsp" class="niceform">
<input name="qx" type="hidden" value="1">
<label for="textinput">帐号:</label>
<input type="text" id="textinput" name="uid" size="12" />
<br />
<label for="passwordinput">密码:</label>
<input type="password" id="passwordinput" name="pwd" size="12" />
<br />
<label for="passwordinput">验证:</label>
<input type="text" id="passwordinput" name="ad" size="4" />
<br />
<input name="Submit1" type="submit" id="Submit1" value="提交" />
<input type="reset" name="Submit2" value="重置" />
</form>

处理页面:

<%@ page contentType="text/html; charset=gb2312" language="Java" import="java.sql.*" errorPage="" %>
<%@ include file="conn.jsp" %>
<%
request.setCharacterEncoding("gb2312");
String sqx=request.getParameter("qx");
int qx =Integer.parseInt(sqx);
String uid=request.getParameter("uid");
String pwd= request.getParameter("pwd");
String sql=null;

switch(qx){
case 1:sql="select * from admin where admin='"+uid+"' and pwd='"+pwd+"'";break;
case 2:sql="select * from department where d_admin='"+uid+"' and d_pwd='"+pwd+"'";break;
case 3:sql="select * from student where s_name='"+uid+"' and s_pwd='"+pwd+"'";break;
}
rs=stmt.executeQuery(sql);

boolean flag=false;
if(rs.next()){flag=true;}

if(flag==true)
{
session.setAttribute("uid",uid);
session.setAttribute("pwd",pwd);
session.setAttribute("type",sqx);
session.setAttribute("sflag","qgzx");
switch(qx){
case 1:response.sendRedirect("admin.jsp");break;
case 2:response.sendRedirect("d_manage.jsp");break;
case 3:response.sendRedirect("s_manage.jsp");break;
}
}
else{
session.setAttribute("uid",null);
session.setAttribute("pwd",null);
session.setAttribute("type",null);
%><jsp:forward page="error.jsp"/><%
}
}
catch(SQLException e2){out.println(e2);}
//rs.close();
//conn.close();
%>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式