javaee编写登陆界面
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javaee编写登陆界面相关的知识,希望对你有一定的参考价值。
软件151朱实友
login.jsp
logincheck.jsp
<%@ page import="java.sql.*" language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <jsp:useBean id="db" class="Bean.DBBean" scope="page" /> <% request.setCharacterEncoding("UTF-8"); String username=(String)request.getParameter("username"); String password=(String)request.getParameter("password");//取出login.jsp的值 //下面是数据库操作 String sql="select * from Table_1 where name="+"‘"+username+"‘";//定义一个查询语句 ResultSet rs=db.executeQuery(sql);//运行上面的语句 if(rs.next()) { /* if(password.equals(rs.getString(2))) { } */ if(password.equals(rs.getObject("password"))){ response.sendRedirect("loginsuccess.jsp"); } else{ out.print("<script language=‘javascript‘> alert(‘密码错误‘);</script>"); response.setHeader("refresh", "0;url=login.jsp"); } } else { out.print("<script language=‘javaScript‘> alert(‘账号错误——else‘);</script>"); response.setHeader("refresh", "0;url=login.jsp"); } %> </body> </html>
以上是关于javaee编写登陆界面的主要内容,如果未能解决你的问题,请参考以下文章