网站登录界面调用MySQL数据库用户名和密码是出现错误,我写的jsp代码如下,报错内容截图,希望帮我看一下

<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<html>
<head>
	<title>Java Web</title>

</head>

<body>
     
	<%
       
   Connection conn=null;
    try
    {
       String uid=request.getParameter("uid");
       String pwd=request.getParameter("pwd");

       Class.forName("com.mysql.jdbc.Driver");
      String url="jdbc:mysql://localhost:3306/news";
       conn=DriverManager.getConnection(url,"root","123456");
             
       Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from tb1");

       

      while(rs.next())
       {
        String username=rs.getString(1);
        String password=rs.getString(2);
       }
       if(username.equals(uid) && password.equals(pwd))
         {
	       session.setAttribute("login","ok");
	       session.setMaxInactiveInterval(-1);
       	   response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
	       response.setHeader("Location","main.jsp"); 
         } 
       else 
       {
	    out.println("用户名或密码输入错误!");
	    break;
       }
    }
    catch(Exception e)
    {
     out.println("some error");
      out.println(e.toString());
    }
    finally
    {
      conn.close();
    }
%>
</body>
</html>

浏览器报错如下:

http://img.mukewang.com/573ffbdb0001066206000514.jpg

UDUN
浏览 2623回答 1
1回答

陌卍言

请看错误代码,你的username和password在括号里面,你在括号外面引用,所以编译报错了
打开App,查看更多内容
随时随地看视频慕课网APP