日期:2014-05-17  浏览次数:20936 次

求教!identity判断失误
我想实现通过判断账号密码和身份三个条件有不同的登录效果,下面是我的代码(非常不规范,请见谅!)
start.jsp

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page import ="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import ="java.util.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>login</title>
</head>

<body>
<table width="694" align="center">
  <tr>
  <th scope="col"><form id="form1" name="form1" method="post" action="login.jsp">
  <table width="652">
  <tr>
  <th width="50" scope="col">账户</th>
  <th width="175" scope="col"><label>
  <input type="text" name="account" />
  </label></th>
  <th width="51" scope="col">密码</th>
  <th width="177" scope="col"><label>
  <input type="password" name="password" />
  </label></th>
  <th width="52" scope="col">身份</th>
  <th width="71" scope="col"><select name="identity">
  <option value="供应商">供应商</option>
  <option value="管理员">管理员</option>
  </select>
  </th>
  <th width="44" scope="col"><input type="submit" name="Submit" value="登录" /></th>
  </tr>
  </table>
  </form>
  </th>
  <th scope="col"><form id="form2" name="form2" method="post" action="register.jsp">
  <input type="submit" name="Submit2" value="注册" />
  </form>
  </th>
  </tr>
</table>
</body>
</html>

login.jsp

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page import ="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import ="java.util.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>login</title>
</head>

<body text="#FF0000">
<div align="center">
  <%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url= "jdbc:mysql://localhost:3306/graduationproject?user=root&password=123";