主题:[讨论]form表单为什么不能提交
<jsp:useBean id = "Connection" class= "MyBean.DbBean" scope="page"/>
<jsp:useBean id="cart" class="MyBean.CartBean" scope="session"/>
<%
Connection conn = Connection.getConnect();
ResultSet rs = null;
String sql1 = "select OrderId from OrderTotal";
String sql2 = "insert into OrderTotal(OrderId,OrderEntryId,ProdId,Number) values(?,?,?,?)";
Statement s = conn.createStatement();
PreparedStatement ps = conn.prepareStatement(sql2);
Enumeration en = cart.getEnumeration();
String[] it;
String oid;
String eid;
int i = 0;
int j = 0;
String submit = request.getParameter("submit");
if( submit==null) submit="";
//submit=codeString(submit);
//out.print("haha");
if(submit.equals("确认")) {
//out.print("haha");
rs = s.executeQuery(sql1);
while(rs.next()) i++;
oid = String.valueOf(i + 1);
while( oid.length() < 8) oid = "0"+oid;
while(en.hasMoreElements()) {
j++;
eid = String.valueOf(j + 1);
it=(String[])en.nextElement();
try {
ps.setString(1,oid);
ps.setString(2,eid);
ps.setString(3,codeString(it[0]));
ps.setInt(4,Integer.parseInt(it[2]));
ps.execute();
}catch(SQLException e) {
out.print(e.getMessage());
}
}
}
Connection.disConnect( rs, ps, s, conn );
%>
<form name="form" method="post" action="OrderSuccess.jsp">
<input type="submit" name="submit" value="确认" />
</form>
当我点击提交的时候,为什么if(submit.equals("确认")) 这里会是false而不能往下执行呢?
<jsp:useBean id="cart" class="MyBean.CartBean" scope="session"/>
<%
Connection conn = Connection.getConnect();
ResultSet rs = null;
String sql1 = "select OrderId from OrderTotal";
String sql2 = "insert into OrderTotal(OrderId,OrderEntryId,ProdId,Number) values(?,?,?,?)";
Statement s = conn.createStatement();
PreparedStatement ps = conn.prepareStatement(sql2);
Enumeration en = cart.getEnumeration();
String[] it;
String oid;
String eid;
int i = 0;
int j = 0;
String submit = request.getParameter("submit");
if( submit==null) submit="";
//submit=codeString(submit);
//out.print("haha");
if(submit.equals("确认")) {
//out.print("haha");
rs = s.executeQuery(sql1);
while(rs.next()) i++;
oid = String.valueOf(i + 1);
while( oid.length() < 8) oid = "0"+oid;
while(en.hasMoreElements()) {
j++;
eid = String.valueOf(j + 1);
it=(String[])en.nextElement();
try {
ps.setString(1,oid);
ps.setString(2,eid);
ps.setString(3,codeString(it[0]));
ps.setInt(4,Integer.parseInt(it[2]));
ps.execute();
}catch(SQLException e) {
out.print(e.getMessage());
}
}
}
Connection.disConnect( rs, ps, s, conn );
%>
<form name="form" method="post" action="OrderSuccess.jsp">
<input type="submit" name="submit" value="确认" />
</form>
当我点击提交的时候,为什么if(submit.equals("确认")) 这里会是false而不能往下执行呢?