.
1 / 17
院 系: 计算机科学学院
专 业: 软件工程
年 级:08级
课程名称: 软件体系结构
指导 孟博
20xx4月26 日
年级
08级
班号
1班
学号
"method="post">
用户名:
<Inputtype="text"name="uid"maxlength=8style="width:150"><br>
密码 :
<Inputtype="password"name="upwd"maxlength=8style="width:150">
<br>
<Inputtype="submit"value="登陆">
<Inputtype="reset"value="取消">
</form>
<formaction=""method="post">
<inputtype="submit"value="注册">
</form>
</center>
</body>
</html>
〔2〕、验证界面模块<>:
<% page language="java" contentType="text/html; charset=UTF-8"
.
6 / 17
pageEncoding="UTF-8"%>
<% page import=".*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML Transitional//EN" " ">
<html>
<head>
<meta -equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% //获取浏览器客户端提交的用户信息
String user=<"uid">;
String password=<"upwd">;
if<user!=null&&!<"">>{
try{ //连接数据库验证用户身份
/*连接数据库*/
Connection con=null;
<"">
.newInstance<>;
String url="jdbc:sqlserverlocalhost:1433;DatabaseName=stud";
con=<url,"sa","0806">;
.
7 / 17
Statement stmt=<>;
String sql="select * from student where name='"+user+"'";
sql+=" and num='" +password +"'";//准备查询语句
ResultSet rs=<sql>;
if<<>>{
<"login","ok">;//验证通过之后,跳转到后继页面
<"uname",user>;
%>
<jsp:forward page=""/>
<%
}else
<"错误的用户名和密码">; //验证未通过,显示错误信息
<"<a href=>返回</a>">;
}catch<Exception ee>{
<"登陆失败! <br> <a href=>返回</a>">;
<>;
}
}else{
<"请先登陆!">; //验证未通过,显示验证信息
<"<a href=>返回</a>">;
}
%>
.
8 / 17
</body>
</html>
<3>、显示登陆成功与否界面模块〔〕:
<html>
<head>
<me
基于BS的用户登陆系统方案 来自淘豆网m.daumloan.com转载请标明出处.