javax.servlet.ServletException: No data foundACCESS 数据库表 中
字段 user(姓名) pd(密码) rang(等级"0"or"1") ...
     Mary       111        1
     Pop        444        0
     Song       666        0
     ...当登录除 Mary 以外的 都无问题dlu.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<table width="100%" border="0">
  <tr>
    <th height="100" bgcolor="#66FFCC">&nbsp;</th>
  </tr>
</table>
<table width="60%" border="0">
<form method="POST" action="login.jsp">
 <%
//是否登陆
if((String)session.getValue("user_name")!=null) 
               {
String name=(String)session.getAttribute("user_name");
sql="select * from login where user='"+name+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
%>
  <tr> 
    <td width="10%">用户名:</td>
    <td width="13%"><%=rs.getString("user")%></td>
    <td width="7%">卡号:</td>
    <td width="15%"><%=rs.getString("cd")%></td>
    <td width="15%">工作卖场:</td>
    <td width="20%"><%=rs.getString("st")%></td>
    <td width="20%"><a href="index.jsp?loginout=true">退出登录</a></td>
  </tr>
   <%
} }else
 //没有登陆
 {
 %>
  <tr> 
    <td height="10">用户名:</td>
    <td><input name="user_name" type="text" class=input id="user_name" style="FONT-SIZE: 12px; WIDTH: 110px" size="10" maxlength="18"></td>
    <td>密码:</td>
    <td><input style="FONT-SIZE: 12px; WIDTH: 110px" type="password" name="user_pass" size="10" class=input maxlength="18"></td>
    <td><input type="submit" name="Submit2" value="登录"></td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <%
}//判断登陆结束String loginout=request.getParameter("loginout");//退出登陆
if(loginout!=null)
{
if(loginout.compareTo("true")==0)
{
session.removeAttribute("user_name");
response.sendRedirect("index.jsp");
}
}
%>
  </form>  
</table>
<p>&nbsp;</p>login.jsp
<%@ include file="conn1.jsp"%>
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%
String user_name=request.getParameter("user_name");
String user_pass=request.getParameter("user_pass");
sql="select * from login where user='"+user_name+"'"+" and pd='"+user_pass+"'";
rs=stmt.executeQuery(sql);
if(!rs.next())
{
out.print("<script>alert('你输入的用户不存在或密码错误,请重新登录!');window.history.go(-1);</script>");
}
else{
 session.setAttribute("user_name",""+rs.getString("user")+"");
  session.setAttribute("cd",""+rs.getString("cd")+"");
     //  session.setAttribute("user_type","yes");
 response.sendRedirect("index.jsp");
 
}
%>