1.设计表
2.javabean
package com.cir.bean; public class User { private int id; private String username; private String password; private int permissionId; private int status; private String position; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public int getPermissionId() { return permissionId; } public void setPermissionId(int permissionId) { this.permissionId = permissionId; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } }
package com.cir.bean; //公文信息 public class Doc { private int id; private String tipplace; //副厂长审核意见位置 private String tipfplace; //厂长审签意见位置 private int deletestaus; //公文的删除状态 private int callback; //该公文回执信息的接受状态 private String title; private String owner;//发送者 private String receiver; private String time; private int status; //流转状态 private int result; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } public String getReceiver() { return receiver; } public void setReceiver(String receiver) { this.receiver = receiver; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public int getResult() { return result; } public void setResult(int result) { this.result = result; } public String getPlace() { return place; } public void setPlace(String place) { this.place = place; } private String place; //公文存储位置 public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTipplace() { return tipplace; } public void setTipplace(String tipplace) { this.tipplace = tipplace; } public String getTipfplace() { return tipfplace; } public void setTipfplace(String tipfplace) { this.tipfplace = tipfplace; } public int getDeletestaus() { return deletestaus; } public void setDeletestaus(int deletestaus) { this.deletestaus = deletestaus; } public int getCallback() { return callback; } public void setCallback(int callback) { this.callback = callback; } }
package com.cir.bean; //用户权限 public class Permission { private int id; private int permission; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getPermission() { return permission; } public void setPermission(int permission) { this.permission = permission; } }
2.工具类
package com.cir.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBUtil { //数据库连接地址 private static String URL = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC"; //数据库用户名 private static String UserName = "root"; //数据库密码 private static String Password = "18735"; public static Connection getConnection() { Connection Conn=null; try { Class.forName("com.mysql.cj.jdbc.Driver"); System.out.println("加载驱动成功"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { //通过DriverManager类的getConenction方法指定三个参数,连接数据库 Conn = DriverManager.getConnection(URL, UserName, Password); System.out.println("连接数据库成功!!!"); //返回连接对象 //return Conn; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); } return Conn; } //还应涉及对数据表的操作 }
3.相关jsp页面
<%@ page 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>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script
src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<title>登录</title>
<style type="text/css">
* {
padding: 0px;
margin: 0px;
}
.header {
100%;
height: 120px;
background-color: gray;
text-align: center;
}
.container {
100%;
height: 780px;
position: relative;
background-color: blue;
}
.login {
500px;
height: auto;
background-color: white;
position: absolute;
top: 200px;
left: 500px;
border-radius: 8px;
}
label {
float: left;
100px;
margin-top: 7px;
margin-right: 5px;
}
.form-control {
60%;
}
.logtip {
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 2px solid red;
text-align: center;
}
.form-group {
margin-left: 40px;
margin-top: 40px;
}
.btn {
height: 50px;
100px;
float: left;
border-radius: 10px;
}
.logbtn {
margin-right: 20px;
}
.btnbag {
margin-left: 140px;
margin-right: 140px;
height: 50px;
overflow: hidden;
margin-top: 30px;
margin-bottom: 40px;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
</head>
<body>
<div class="header">
<h2>河北金力集团公文流转系统</h2>
</div>
<div class="container">
<div class="login">
<h2 class="logtip">登录</h2>
<form action="login_do" method="post"></form>
<div class="from-group">
<lable for="username">用户名</lable>
<input type="text" calss="form-control" id="username"
name="username">
</div>
<div class="from-group">
<lable for="password">密码</lable>
<input type="password" calss="form-control" id="password"
name="password">
</div>
<div class="btnbag">
<input type="button" class="btn btn-primary logbtn"
onclick="login()" value="登录"> <input type="button"
class="btn btn-primary mangbtn" onclick="entermang()" value="进入管理">
</div>
</form>
</div>
</div>
</body>
<script>
function login()
{
var username=$("#username").val();
var pasword=$("password").val();
if(username==""||password=="")
alert("请将信息填写完整!");
else
{
$.post
{
"login_do"
{
username:username,
password:password},
function(data)
{
if(data=="yes")
{
alert("登录成功!");
window.location="backmainpage.jsp";
}
else
{
alert("用户名或密码错误!或用户已被暂停使用!");
},"text"
};
}
}
}
</script>
</html>