一:javaee会议管理实现过程之登录功能的代码(完整详细有注释)

目录

 

 

1.导入初始化的文件,配置web.xml的默认欢迎页面为login.jsp

2.实现VO类(viewer object)类或者叫实体类

3.编写Employee对应的数据访问层

4.编写登录的逻辑service 服务层

5.前面已经在service类写好了登录的方法login(),并且也准备好了静态的视图,

6.显示登录失败提示

7.总结:

8.附上项目中要用到的页面

8.数据库(导入就行了)

9.有什么问题欢迎留言


 

1.导入初始化的文件,配置web.xml的默认欢迎页面为login.jsp

静态视图搭建起来

 

2.实现VO类(viewer object)类或者叫实体类

与具体对象有关,表里有多少个字段,就有多少个属性,employee类一共9个

编写了Employee实体类

package com.meeting.vo;
/**
 * 对应Employee表的实体类
 * @author Administrator
 *
 */
public class Employee {
	private Integer employeeid;
	private String employeename;
	private String username;
	private String password;
	private Integer departmentid;//部门id
	private String email;
	private String phone;
	//0表示注册成功,但是没有审核
	private String status="0";
	//2表示普通人工
	private String role="2";
	
	//默认构造方法
	public Employee() {
		super();
	}
	
	//可能会用到的构造方法1
	public Employee(String username, String password, String role) {
		super();
		this.username = username;
		this.password = password;
		this.role = role;
	}
	
	//可能会用到的构造方法2
	public Employee(String employeename, String username, String password,
			Integer departmentid, String email, String phone, String status,
			String role) {
		super();
		this.employeename = employeename;
		this.username = username;
		this.password = password;
		this.departmentid = departmentid;
		this.email = email;
		this.phone = phone;
		this.status = status;
		this.role = role;
	}

	//可能会用到的构造方法3
	public Employee(Integer employeeid, String employeename, String username, String password, Integer departmentid,
			String email, String phone, String status, String role) {
		super();
		this.employeeid = employeeid;
		this.employeename = employeename;
		this.username = username;
		this.password = password;
		this.departmentid = departmentid;
		this.email = email;
		this.phone = phone;
		this.status = status;
		this.role = role;
	}

	public Integer getEmployeeid() {
		return employeeid;
	}

	public void setEmployeeid(Integer employeeid) {
		this.employeeid = employeeid;
	}

	public String getEmployeename() {
		return employeename;
	}

	public void setEmployeename(String employeename) {
		this.employeename = employeename;
	}

	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 Integer getDepartmentid() {
		return departmentid;
	}

	public void setDepartmentid(Integer departmentid) {
		this.departmentid = departmentid;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getStatue() {
		return status;
	}

	public void setStatue(String statue) {
		this.status = statue;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}
	

	
}

 

3.编写Employee对应的数据访问层

Dao层数据访问层,

先不管登录的状态是否被审核成功,先实现用户名的用户和密码是否存在

需要用到mysql数据库的驱动包

现在将连接数据库的EmployeeDAO类设置为一个工厂类,用到单例模式,每次连接后就养成关闭的习惯

弊端是如果并发,会产生冲突,后期会用连接池来解决这个问题

会在这个类写一个main方法来测试看看连接是否成功

为了方便查看,在原来的Employee.java这里新增一个toString方法来打印属性信息

@Override
	public String toString() {
		return "Employee [employeeid=" + employeeid + ", employeename=" + employeename + ", username=" 
				+ username+ ", password=" + password + ", departmentid=" + departmentid + ", email=" 
				+ email + ", phone=" + phone
				+ ", status=" + status + ", role=" + role + "]";
	}

然后在ConnectionFactory.java这个类里

出现错误是还没有导包,导包的时候要细心,不要导错包了

ConnectionFactory.java

package com.meeting.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 获得数据库链接,以及关闭
 * 连接方法getConnection()
 * 关闭方法closeConnection()
 * @author Administrator
 *注:这种方法 是不合理的,面对并发的时候会出现很多问题,无法同时使用
 */


public class ConnectionFactory {
	//声明了静态属性
	private static Connection conn=null;
	
	/**
	 * 返回一个唯一的数据库连接对象
	 * @return
	 */
	public static Connection getConnection(){
		try {
			//加载驱动
			Class.forName("com.mysql.jdbc.Driver");
			//获得链接
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/meeting", "root", "root");
			System.out.println("连接成功!");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return conn;
	}
	
	/**
	 * 关闭数据库连接对象的方法
	 */
	public static void closeConnection(){
		//只要conn不是空的,就可以关掉
		if(conn!=null){
		try {
			conn.close();			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
	}
	
	//定义一个测试的main方法
	public static void main(String[] args) {
		ConnectionFactory.getConnection();
	}
}

EmployeeDAO.java数据访问层

package com.meeting.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.meeting.util.ConnectionFactory;
import com.meeting.vo.Employee;

/**
 * 实现与Employee有关的增删改查操作
 * 
 * @author Administrator
 *
 */
public class EmployeeDAO {
	// 获得一个数据库连接
	private Connection conn = ConnectionFactory.getConnection();

	
	/**方法一:
	 * 根据用户名、密码进行查询,将查询得到的记录封装成Employee对象返回
	 * @param username
	 * @param pwd
	 * @return
	 */
	public Employee selectByNamePwd(String username, String pwd) {
		Employee employee = null;
		try {
			//创建PreparedStatement对象
			PreparedStatement st = null;
			//查询语句
			String sql = "select * from employee where username='" + username + "' and  password='" + pwd + "'";
			st = conn.prepareStatement(sql);
			ResultSet rs = st.executeQuery(sql);
			//判断结果集有无记录,如果有:则把内容取出来,变成一个employee对象,并且返回它
			if (rs.next() == true) {
				
				employee = new Employee();
				
				employee.setEmployeeid(rs.getInt("employeeid"));
				employee.setEmployeename(rs.getString("employeename"));
				employee.setUsername(rs.getString("username"));
				employee.setPhone(rs.getString("phone"));
				employee.setEmail(rs.getString("email"));
				employee.setStatus(rs.getString("status"));
				employee.setDepartmentid(rs.getInt("status"));
				employee.setPassword(rs.getString("password"));
				employee.setRole(rs.getString("role"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			ConnectionFactory.closeConnection();
		}
		return employee;
	}

	/**
	 * 用来测试的main方法
	 * @param args
	 */
	public static void main(String[] args) {
		EmployeeDAO dao = new EmployeeDAO();
		
		//测试wangxh这个对象存不存在
		Employee e = dao.selectByNamePwd("wangxh", "123");
		if (e != null) {
			//存在则打印出来
			System.out.println(e);
		} else {
			//不存在则打印失败
			System.out.println("登录失败");
		}
	}

}

 

右击运行java  Application

得到:(失败是因为密码是错误的)

把上面的密码改成1,会自动在toString方法打印出来

 

4.编写登录的逻辑service 服务层

因为上面的方法只是通过查询数据库中用户名和密码是否存在,

并没有用到status状态来判断是否是审核通过的用户,因此现在编写

EmployeeService类来进行逻辑审核

业务逻辑肯定会使用到数据逻辑,而且多个业务逻辑可能会使用到相同的数据逻辑

即:可能很多个service会用到数据层中查询用户名密码是否存在的selectByNamePwd()方法

所以service服务层肯定会用到dao数据层

 

完整源码

package com.meeting.service;

import com.meeting.dao.EmployeeDAO;
import com.meeting.vo.Employee;

/**
 * 服务类,封装与Employee有关的业务逻辑
 * 
 * @author Administrator
 *
 */
public class EmployeeService {

	// 关联DAO类,因为登录的话需要使用到查询
	private EmployeeDAO dao = new EmployeeDAO();

	/**
	 * 登录逻辑 :
	 * 用户名密码如果不正确,登录失败;
	 * 用户名密码正确,再看status的值,当且仅当status是1,登录成功
	 * flag=3:用户名密码不正确;
	 * flag=1:登录成功;
	 * flag=0:注册过,但是正在审核中;
	 * flag=2:注册过,审核没通过。
	 */
	public int login(String username, String pwd) {
		//默认为3
		int flag = 3;
		
		//先进行用户名密码来查看
		Employee e = dao.selectByNamePwd(username, pwd);
		
		//当e非空
		if (e != null) {
			
			//获取status
			String status = e.getStatus();
			
			if (status != null && status.equals("1")) {
				flag = 1;
			}

			if (status != null && status.equals("0")) {
				flag = 0;
			}

			if (status != null && status.equals("2")) {
				flag = 2;
			}
		}
		return flag;
	}
	
	/**
	 * 测试用户名密码是否存在,如果存在则查看他的status
	 * @param args
	 */
	public static void main(String[] args) {
		EmployeeService service = new EmployeeService();
		int flag = service.login("wangmin", "1");
		System.out.println(flag);

	}

}

Employee表

运行结果(尽量把每一种结果都涉及到)

 

 

如果用户名密码重复,然后状态不同,会输出第一状态个,而不是后面的状态

PS:当访问login.jsp的时候,会直接用到service类的login方法,

 

5.前面已经在service类写好了登录的方法login(),并且也准备好了静态的视图,

现在要做的是把业务层和视图连接起来.需要用到Controller层

也就是servlet.

 

创建servlet类,需要新建的是servlet类而不是java类

 

Servlet的作用:

Servlet控制器的作用是通过getParameter收集前端页面的请求,

把在页面输入的用户名和密码取出来,然后传给EmployeeService对象

调用login()方法得到不同的返回值,根据返回值得到不同的结果,

再跳到不同的页面

 

页面调用Servlet:

在页面的表单中action设置为特定的Servlet的url-pattern

然后在web.xml中设置

这样就可以直接在网站中使用login方法了

 

完整源码

package com.meeting.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.meeting.service.EmployeeService;

/**
 * Servlet implementation class LoginServlet
 */
// @WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public LoginServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取请求参数,username,pwd ,得到用户在表单输入的用户名和密码
		String username = request.getParameter("username");
		String password = request.getParameter("pwd");

		// 调用业务逻辑,login方法
		EmployeeService service = new EmployeeService();
		
		//定义一个flag来获得login的返回值
		int flag = service.login(username, password);

		// 根据返回值不同,跳转到不同视图(返回值有四种,这里只写两种,一个成功一个失败
		if (flag == 1) {
			//成功
			request.getRequestDispatcher("index.jsp").forward(request, response);
		} else {
			//失败
			request.getRequestDispatcher("login.jsp").forward(request, response);
		}
	}

}

 

配置web.xml

 <servlet>
   <servlet-name>LoginServlet</servlet-name>
   <servlet-class>com.meeting.servlet.LoginServlet</servlet-class>
   </servlet>
   <servlet-mapping>
   <servlet-name>LoginServlet</servlet-name>
   <url-pattern>/LoginServlet</url-pattern>
   </servlet-mapping>

servlet-name 内容可以随便选,两个servlet-name是一样的就行

servlet-class: 包名+类名

url-pattern:打开浏览器时候的url

 

更改login.jsp

为了自己方便,这里新增一个信息

 

运行tomcat

 

登录成功

 

 

如果登录失败会回到当前页面

 

看控制台,因为只操作了两次,然后数据库都是连接成功的(因为配置好了)

然后第一次是输入正确的用户名密码,第二次是失败的,所以会跳回当前页面(类似刷新)

 

目前项目进行到这里的时候,登录失败的用户游戏体感很差,因为他并不知道错误在哪里,所以现在要进一步的进行功能完善

6.显示登录失败提示

可以修改控制器(控制器知道发生了什么

)LoginServlet , 根据login()方法的返回值,存储不同的请求属性,

然后在login.jsp加入脚本,获取请求属性msg,并且显示到jsp页面

LoginServlet 修改一:

		//定义一个flag来获得login的返回值
		int flag = service.login(username, password);

		// 根据返回值不同,跳转到不同视图,并且传递不同的提示信息属性msg(4种齐全了
		//脚本通过setAttribute来设置
		if (flag == 1) {
			//成功
			request.getRequestDispatcher("index.jsp").forward(request, response);
		} else {
			//失败
			if(flag==0){
				request.setAttribute("msg", "正在审核,请耐心等待。");
			}
			if(flag==2){
				request.setAttribute("msg", "审核未通过,请核实后重新注册。");
			}
			
			if(flag==3){
				request.setAttribute("msg", "用户名或密码错误,请重试。");
			}
			request.getRequestDispatcher("login.jsp").forward(request, response);
		}

 

login.jsp 修改二:

<%
					String msg = (String) request.getAttribute("msg");
				%>
				<!-- 如果不为空才显示,为空就什么也不显示 -->
				<%
					if (msg != null) {
				%>
				<tr>
					<td>提示信息:</td>
					<td><font color='red'> <%=msg%>
					</font></td>
				</tr>
				<%
					}
				%>

修改位置:

 

运行效果:

密码或用户名错误

成功啦~

 

7.显示登录成功后的欢迎信息

右上角可以显示真名

修改三处:

 

一:

在EmployeeService里声明Employee变量,保存登录成功后的

员工对象,并且提供一个方法去返回这个对象

 

二:

修改LoginServlet

直接登录成功后把员工的姓名保存在会话中

跳转到视图前,用session存起来

 

三:

修改top.jsp

 

 

修改后的代码

EmployeeService.java

package com.meeting.service;

import com.meeting.dao.EmployeeDAO;
import com.meeting.vo.Employee;

/**
 * 服务类,封装与Employee有关的业务逻辑
 * 
 * @author Administrator
 *
 */
public class EmployeeService {

	// 关联DAO类,因为登录的话需要使用到查询
	private EmployeeDAO dao = new EmployeeDAO();
	
	// 保存登录成功后的Employee对象
	private Employee loginedEmployee=new Employee();

	/**
	 * 登录逻辑 :
	 * 用户名密码如果不正确,登录失败;
	 * 用户名密码正确,再看status的值,当且仅当status是1,登录成功
	 * flag=3:用户名密码不正确;
	 * flag=1:登录成功;
	 * flag=0:注册过,但是正在审核中;
	 * flag=2:注册过,审核没通过。
	 */
	public int login(String username, String pwd) {
		//默认为3
		int flag = 3;
		
		//先进行用户名密码来查看
		Employee e = dao.selectByNamePwd(username, pwd);
		
		//当e非空
		if (e != null) {
			
			//登录成功后把对象保存
			loginedEmployee=e;
			
			//获取status
			String status = e.getStatus();
			
			if (status != null && status.equals("1")) {
				flag = 1;
			}

			if (status != null && status.equals("0")) {
				flag = 0;
			}

			if (status != null && status.equals("2")) {
				flag = 2;
			}
		}
		return flag;
	}
	
//	返回登录成功后的员工对象
	public Employee getLoginedEmployee(){
		return loginedEmployee;
	}
	
	/**
	 * 测试用户名密码是否存在,如果存在则查看他的status
	 * @param args
	 */
	public static void main(String[] args) {
		EmployeeService service = new EmployeeService();
		int flag = service.login("天才英俊", "1");
		System.out.println(flag);

	}

}

 

LoginServlet.java

 

 

top.jsp

<div class="header-quicklink">
			<!-- 欢迎您,<strong>admin</strong> -->
			<%
				String employeename = (String) session.getAttribute("employeename");
			%>
			欢迎您,<strong><%=employeename%></strong> <a href="#">[修改密码]</a>

 

编译遇到中文问题

 

7.总结:

使用MVC模式构建Web应用,

通过请求参数传递客户输入信息,

使用会话属性传递数据,

中文处理

  

 

8.附上项目中要用到的页面

0.1html



----------------------------------
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">		
		<title>天才英俊会议记录</title>
		<link rel="stylesheet" type="text/css" href="styles/common03.css"/>
		
	</head>
	<body>
		欢迎使用天才英俊会议管理系统~
	</body>
</html>



0.2html



----------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
 <link rel="stylesheet" href="styles/common.css"/>
</head>
<body>

		<div class="page-footer">
            <hr/>
           	 更多问题,欢迎联系<a href="mailto:webmaster@eeg.com">管理员</a>
            <img src="images/footer.png" alt="CoolMeeting"/>
        </div>

</body>
</html>


index.jsp


----------------------------------

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>会议管理系统</title>
</head>
<frameset rows="150,*,93" cols="*" framespacing="0" frameborder="no" border="0">
 <frame src="top.jsp" name="topFrame" scrolling="No" noresize="noresize" id="topFrame"  marginwidth="0" marginheight="0"  frameborder="0" />
 <frameset cols="260,*" id="frame">
	<frame src="left.jsp" name="leftFrame" noresize="noresize" marginwidth="110px" marginheight="0" frameborder="0" scrolling="auto" target="main"  />
	<frame src="01.html" name="main" marginwidth="50px" marginheight="40px" frameborder="0" scrolling="auto" target="_self"  />
    </frameset>
 <frame src="02.html" name="bottomFrame" scrolling="No" noresize="noresize" id="bottomFrame" marginwidth="0" marginheight="0"/>
</frameset><noframes></noframes>
</html>



left.jsp


----------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="styles/common02.css"/>
</head>
<body>
            <div class="page-sidebar">
                <div class="sidebar-menugroup">
                    <div class="sidebar-grouptitle">个人中心</div>
                    <ul class="sidebar-menu">
                        <li class="sidebar-menuitem"><a href="01.html" target="main">最新通知</a></li>
                        <li class="sidebar-menuitem active"><a href="01.html" target="main">我的预定</a></li>
                        <li class="sidebar-menuitem"><a href="01.html" target="main" >我的会议</a></li>
                    </ul>
                </div>
              
                <div class="sidebar-menugroup">
                    <div class="sidebar-grouptitle">人员管理</div>
                    <ul class="sidebar-menu">
                        <li class="sidebar-menuitem"><a href="01.html"  target="main">部门管理</a></li>
                        <li class="sidebar-menuitem"><a href="01.html" target="main">注册审批</a></li>
                        <li class="sidebar-menuitem"><a href="01.html" target="main">搜索员工</a></li>
                    </ul>
                </div>              
                <div class="sidebar-menugroup">
                    <div class="sidebar-grouptitle">会议预定</div>
                    <ul class="sidebar-menu">
                        <li class="sidebar-menuitem"><a href="01.html" target="main">添加会议室</a></li>
                        <li class="sidebar-menuitem"><a href="01.html"target="main">查看会议室</a></li>
                        <li class="sidebar-menuitem"><a href="01.html"target="main">预定会议</a></li>
                       
                    </ul>
                </div>
            </div>
</body>
</html>



login.jsp


----------------------------------
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>天才英俊会议管理系统</title>
<link rel="stylesheet" href="styles/common.css" />
</head>
<body>

	<div class="page-content">
		<div class="content-nav">登录</div>
		<form action="LoginServlet" method="post">
			<fieldset>
				<legend>登录信息</legend>

				<%
					String msg = (String) request.getAttribute("msg");
				%>
				<!-- 如果不为空才显示,为空就什么也不显示 -->
				<%
					if (msg != null) {
				%>
				<tr>
					<td>提示信息:</td>
					<td><font color='red'> <%=msg%>
					</font></td>
				</tr>
				<%
					}
				%>

				<table class="formtable" style="width: 50%">
					<tr>
						<td>账号名:</td>
						<td><input id="accountname" name="username" type="text" /></td>
					</tr>
					<tr>
						<td>密码:</td>
						<td><input id="new" name="pwd" type="password" /></td>
					</tr>
					<tr>
						<td colspan="2" class="command"><input type="submit"
							value="登录" class="clickbutton" /> <input type="button"
							value="返回" class="clickbutton" onclick="window.history.back();" />
							<input type="button" value="注册" class="clickbutton"
							onclick="window.location.href='#';" /></td>
					</tr>
				</table>
			</fieldset>
		</form>
	</div>
	</div>

</body>
</html>


top.jsp
-----------------------------------------------------

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="styles/common.css" />
</head>

<body>
	<div class="page-header">
		<div class="header-banner">
			<br />
			<img src="images/header.png" alt="CoolMeeting" />
		</div>
		<div class="header-title">欢迎访问天才英俊会议管理系统</div>
		<div class="header-quicklink">
			<!-- 欢迎您,<strong>admin</strong> -->
			<%
				String employeename = (String) session.getAttribute("employeename");
			%>
			欢迎您,<strong><%=employeename%></strong> <a href="#">[修改密码]</a>
		</div>
	</div>
</body>
</html>

 

styles下的css

common.css
---------------------------
* {
    font-family:微软雅黑, Arial;
    padding: 0;
    margin: 0;
    font-size:14px;
}

body{
    width:1000px;
    margin:10px auto;
    background-color:lightgray;
}

a{
    color:gray;
    text-decoration:none;
}

a:hover{
    color:red;
    font-weight:bold;
    text-decoration:none;
}

a:visited{
    text-decoration:none;
}

img{
    height:100%;
    vertical-align:middle;
}

fieldset{
    padding:10px;
}

legend{
    font-size:16px;
    font-weight:bold;
}

input[type="text"]{
    width:150px;
}

input[type="password"]{
    width:150px;
}

textarea{
    width:80%;
    text-align:left;
}

h1, h2, h3 {
    text-align:center;
}

.page-header{
    position:relative;
    height:60px;
    background-color:#b0b0b0;
    border-radius:10px;   
    margin-bottom:10px;
    padding:10px;
}

.page-header .header-banner{
    float:left;
    width:20%;
    vertical-align:middle;
    height:100%;
}

.page-header .header-title{
    float:left;
    width:60%;
    text-align:center;
    font-size:28px;
    padding-top:10px;
}

.page-header .header-quicklink{
    float:right;
    padding-top:40px;
}

.page-body{
    padding:10px;
}

.page-sidebar{
    width:150px;
    float:left;
}

.page-content{
    width:830px;
    float:right;
}

.page-footer{
    clear:both;
    height:60px;
    text-align:center;
    padding-top:20px;
}

.sidebar-menugroup{
    padding-bottom:10px;
}

.sidebar-grouptitle{
    width:100%;
    font-size:16px;
    font-weight:bold;
    cursor:pointer;
}

.sidebar-menu{
    list-style:none;
    padding-left:20px;
}

.page-content .content-nav{
    padding:0 0 10px 0;
}

.listtable{
    width:100%;
    border:1px solid #afafaf;
    border-collapse:collapse;
    margin-bottom:10px;
}

.listtable caption{
    text-align:left;
    font-size:16px;
    padding:2px;
    font-weight:bold;
}

.listtable td{
    padding:5px;
    border: 1px solid gray;
    font-size:12px;
    text-align:center;
}

.listtable tr:nth-child(2n){
    background-color : #ebeaea;
}

.listtable .listheader{
    background-color:skyblue;
    text-align:center;
}

.listtable .listheader th{
    padding:5px;
    border: 1px solid gray;
}

.formtable {
    width:100%;
    padding: 0 auto;
}

.formtable td{
    padding:5px;
}

.formtable tr td:first-child{
    vertical-align:top;
}

.formtable input[type="radio"] + label{
    margin-right:10px;
}

.formtable .command{
    text-align:center;
}

.formtable .command .clickbutton{
    margin:0 10px;
}

.pager-header{
    
}

.pager-header .header-info{
    float:left;
}

.pager-header .header-info .info-number{
    font-weight:bold;
}

.pager-header .header-nav{
    float:right;
}

.pager-header .header-nav .nav-number{
    width:30px;
    margin:0 5px;
}

.clickbutton {  
    border: 1px solid #4D4D4D;
    padding: 2px 10px;
    cursor:pointer;
    font-size:14px;
}

.error {
    color:red;
}

/*
新增加的样式
*/
.emp_info{
	width:24px;
}
.msg{
	width:154px;
}




common02.css
---------------------------
/*通用样式*/
* {
    font-family:寰蒋闆呴粦, Arial;
   
    font-size:15.5px;
}
/*body的样式*/
body{
    background-color:lightgray;
}
/*链接的样式*/
a{
    color:gray;
    text-decoration:none;
}
/*伪类*/
a:hover{
    color:red;
    font-weight:bold;
    text-decoration:none;
}

a:visited{
    text-decoration:none;
}

img{
    height:100%;
    vertical-align:middle;
}

fieldset{
    padding:10px;
}

legend{
    font-size:16px;
    font-weight:bold;
}

input[type="text"]{
    width:150px;
}

input[type="password"]{
    width:150px;
}

textarea{
    width:80%;
    text-align:left;
}

h1, h2, h3 {
    text-align:center;
}

.page-body{
    padding:10px;
}

.page-sidebar{
	 
	text-align:left;
    width:150px;
   
}

.page-content{
    width:830px;
    
}


.sidebar-grouptitle{
    width:100%;
    font-size:16px;
    font-weight:bold;
    cursor:pointer;
	
}

.sidebar-menu{
	letter-spacing:3px;
    list-style:none;
    padding-left:20px;
}




common03.css
------------------------------

/*通用样式*/
* {
    font-family:寰蒋闆呴粦, Arial;
   
    font-size:14px;
}
/*body的样式*/
body{
	 padding: 0;
    margin: 0;
    width:1000px;
    
    background-color:lightgray;
}
/*链接的样式*/
a{
    color:gray;
    text-decoration:none;
}
/*伪类*/
a:hover{
    color:red;
    font-weight:bold;
    text-decoration:none;
}

a:visited{
    text-decoration:none;
}

img{
    height:100%;
    vertical-align:middle;
}

fieldset{
    padding:10px;
}

legend{
    font-size:16px;
    font-weight:bold;
}

input[type="text"]{
    width:150px;
}

input[type="password"]{
    width:150px;
}

textarea{
    width:80%;
    text-align:left;
}

h1, h2, h3 {
    text-align:center;
}

.page-header{
    position:relative;
    height:60px;
    background-color:#b0b0b0;
    border-radius:10px;   
    margin-bottom:10px;
    padding:10px;
}

.page-header .header-banner{
    float:left;
    width:20%;
    vertical-align:middle;
    height:100%;
}

.page-header .header-title{
    float:left;
    width:60%;
    text-align:center;
    font-size:28px;
    padding-top:10px;
}

.page-header .header-quicklink{
    float:right;
    padding-top:40px;
}

.page-body{
    padding:10px;
}

.page-sidebar{
    width:150px;
    float:left;
}

.page-content{
   width:850px;
   text-align: left;
  
    
}

.page-footer{
    clear:both;
    height:60px;
    text-align:center;
    padding-top:20px;
}

.sidebar-menugroup{
    padding-bottom:10px;
}

.sidebar-grouptitle{
    width:100%;
    font-size:16px;
    font-weight:bold;
    cursor:pointer;
}

.sidebar-menu{
    list-style:none;
    padding-left:20px;
}

.page-content .content-nav{
    padding:0 0 10px 0;
}

.listtable{
    width:100%;
    border:1px solid #afafaf;
    border-collapse:collapse;
    margin-bottom:10px;
}

.listtable caption{
    text-align:left;
    font-size:16px;
    padding:2px;
    font-weight:bold;
}

.listtable td{
    padding:5px;
    border: 1px solid gray;
    font-size:12px;
    text-align:center;
}

.listtable tr:nth-child(2n){
    background-color : #ebeaea;
}

.listtable .listheader{
    background-color:skyblue;
    text-align:center;
}

.listtable .listheader th{
    padding:5px;
    border: 1px solid gray;
}

.formtable {
    width:100%;
    padding: 0 auto;
}

.formtable td{
    padding:5px;
}

.formtable tr td:first-child{
    vertical-align:top;
}

.formtable input[type="radio"] + label{
    margin-right:10px;
}

.formtable .command{
    text-align:center;
}

.formtable .command .clickbutton{
    margin:0 10px;
}

.pager-header{
    
}

.pager-header .header-info{
    float:left;
}

.pager-header .header-info .info-number{
    font-weight:bold;
}

.pager-header .header-nav{
    float:right;
}

.pager-header .header-nav .nav-number{
    width:30px;
    margin:0 5px;
}

.clickbutton {  
    border: 1px solid #4D4D4D;
    padding: 2px 10px;
    cursor:pointer;
    font-size:14px;
}

.error {
    color:red;
}

 

 

images下的图片

 

 

8.数据库(导入就行了)

/*
SQLyog Ultimate v12.4.1 (64 bit)
MySQL - 5.6.14-log : Database - meeting
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`meeting` /*!40100 DEFAULT CHARACTER SET utf8 */;

USE `meeting`;

/*Table structure for table `counter` */

DROP TABLE IF EXISTS `counter`;

CREATE TABLE `counter` (
  `visitcount` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `counter` */

insert  into `counter`(`visitcount`) values 
(99);

/*Table structure for table `department` */

DROP TABLE IF EXISTS `department`;

CREATE TABLE `department` (
  `departmentid` int(16) NOT NULL AUTO_INCREMENT,
  `departmentname` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`departmentid`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

/*Data for the table `department` */

insert  into `department`(`departmentid`,`departmentname`) values 
(1,'技术部'),
(2,'人事部'),
(3,'财务部'),
(4,'行政部'),
(7,'运维部');

/*Table structure for table `employee` */

DROP TABLE IF EXISTS `employee`;

CREATE TABLE `employee` (
  `employeeid` int(16) NOT NULL AUTO_INCREMENT,
  `employeename` varchar(14) CHARACTER SET utf8 DEFAULT NULL,
  `username` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `status` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `departmentid` int(16) DEFAULT NULL,
  `password` varchar(50) DEFAULT NULL,
  `role` varchar(12) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`employeeid`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;

/*Data for the table `employee` */

insert  into `employee`(`employeeid`,`employeename`,`username`,`phone`,`email`,`status`,`departmentid`,`password`,`role`) values 
(1,'天才英俊','admin','10086','xxx@163.com','1',1,'1','2'),
(8,'王晓华','wangxh','13671075406','wang@qq.com','1',1,'1','1'),
(9,'林耀坤','linyk','13671075406','yang@qq.com','1',2,'1','2'),
(10,'熊杰文','xiongjw','134555555','xiong@qq.com','1',3,'1','2'),
(11,'王敏','wangmin','1324554321','wangm@qq.com','2',4,'1','2'),
(12,'林耀坤','linyk','1547896765','kun@qq.com','1',7,'1','2'),
(13,'林耀坤','linyk','13897338822','yao@qq.com','1',1,'2','2'),
(14,'林耀坤','linyk','18908789808','yangyk@qq.com','2',2,'2','2'),
(15,'黄美玲','huangml','huangml@qq.com','13567898765','1',3,'1','2'),
(16,'黄美玲','huangml','huangml@qq.com','13567898765','2',4,'1','2'),
(17,'黄美玲','huangml002','huangml@qq.com','13567898765','2',1,'1','2'),
(20,'王敏','wangmin002','13454332334','wang@qq.com','1',4,'1','2'),
(21,'陈敏','chenm','13559994444','www@aa.com','1',2,'1','2'),
(23,'陈晨','wangm','22·2','11','1',1,'1','2'),
(25,'王晓华','wangxh222','111','1','1',4,'1','2'),
(27,'张三','zhangsan','122','22','0',4,'1','2');

/*Table structure for table `meeting` */

DROP TABLE IF EXISTS `meeting`;

CREATE TABLE `meeting` (
  `meetingid` int(16) NOT NULL AUTO_INCREMENT,
  `meetingname` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `roomid` int(16) DEFAULT NULL,
  `reservationistid` int(16) DEFAULT NULL,
  `numberofparticipants` int(16) DEFAULT NULL,
  `starttime` datetime DEFAULT NULL,
  `endtime` datetime DEFAULT NULL,
  `reservationtime` datetime DEFAULT NULL,
  `canceledtime` datetime DEFAULT NULL,
  `description` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `status` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`meetingid`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=latin1;

/*Data for the table `meeting` */

insert  into `meeting`(`meetingid`,`meetingname`,`roomid`,`reservationistid`,`numberofparticipants`,`starttime`,`endtime`,`reservationtime`,`canceledtime`,`description`,`status`) values 
(25,'ces',5,8,12,'2015-01-12 10:00:00','2015-01-12 12:00:00','2015-01-10 23:02:39',NULL,NULL,'1'),
(26,'测测',7,8,12,'2015-01-12 13:00:00','2015-01-12 15:00:00','2015-01-17 23:04:18','2015-01-11 01:06:20',NULL,'1'),
(27,'我看看',6,8,12,'2015-01-13 23:06:06','2015-01-14 03:06:08','2015-01-10 23:06:33','2015-01-11 01:01:42','我看看','1'),
(28,'运营会',5,8,12,'2015-01-10 23:26:11','2015-01-11 23:26:13','2015-01-10 23:26:26',NULL,'测试','0'),
(29,'市场部会议',6,8,12,'2015-01-10 23:44:22','2015-01-11 23:44:24','2015-01-10 23:44:41',NULL,'市场部','0'),
(30,'内部会议',10,8,12,'2015-01-10 23:55:59','2015-01-11 23:56:01','2015-01-10 23:56:20',NULL,'内部会议','0'),
(31,'我的会议',9,8,12,'2015-01-12 16:33:16','2015-01-13 16:33:18','2015-01-11 16:35:11',NULL,'测试','0'),
(32,'我的会议哈哈',5,8,10,'2015-01-12 16:40:31','2015-01-13 16:40:35','2015-01-11 16:40:50',NULL,'','0'),
(33,'哈哈',6,8,12,'2015-01-12 16:41:45','2015-01-13 16:41:48','2015-01-11 16:42:09','2015-01-12 11:44:57','你好','1'),
(34,'我的会议3',8,8,12,'2015-01-11 16:42:36','2015-01-13 16:42:38','2015-01-11 16:42:51',NULL,'测试','0'),
(35,'我的会议',7,8,12,'2015-01-11 16:44:03','2015-01-11 16:44:05','2015-01-11 16:44:35',NULL,'','0'),
(36,'我问问',7,8,12,'2015-01-11 16:56:57','2015-01-11 16:56:59','2015-01-11 16:57:56','2015-01-11 16:59:57','地点','1'),
(37,'我的会议4',7,8,12,'2015-01-12 16:59:26','2015-01-12 16:59:31','2015-01-11 16:59:49',NULL,'我的会议','0'),
(38,'班会',9,8,12,'2015-01-15 16:46:25','2015-01-16 18:46:53','2015-01-12 11:49:17','2015-01-12 11:49:37','班会','1'),
(39,'测试会议',5,8,12,'2015-01-14 14:41:11','2015-01-15 14:41:14','2015-01-14 14:44:07',NULL,'ss','0');

/*Table structure for table `meetingparticipants` */

DROP TABLE IF EXISTS `meetingparticipants`;

CREATE TABLE `meetingparticipants` (
  `meetingid` int(16) NOT NULL,
  `employeeid` int(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*Data for the table `meetingparticipants` */

insert  into `meetingparticipants`(`meetingid`,`employeeid`) values 
(28,13),
(28,23),
(28,27),
(28,16),
(29,16),
(29,13),
(29,8),
(30,15),
(30,13),
(30,8),
(30,23),
(27,8),
(26,8),
(25,8),
(28,8),
(31,8),
(31,17),
(31,23),
(32,8),
(32,17),
(33,15),
(34,8),
(34,17),
(35,8),
(36,9),
(36,8),
(37,8),
(37,23),
(38,11),
(38,16),
(38,20),
(39,13);

/*Table structure for table `meetingroom` */

DROP TABLE IF EXISTS `meetingroom`;

CREATE TABLE `meetingroom` (
  `roomid` int(16) NOT NULL AUTO_INCREMENT,
  `roomnum` int(16) NOT NULL,
  `roomname` varchar(20) CHARACTER SET utf8 NOT NULL,
  `capacity` int(16) DEFAULT NULL,
  `status` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
  `description` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`roomid`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

/*Data for the table `meetingroom` */

insert  into `meetingroom`(`roomid`,`roomnum`,`roomname`,`capacity`,`status`,`description`) values 
(5,101,'第一会议室',15,'0','公共会议室'),
(6,102,'第二会议室',5,'0','管理部门会议室'),
(7,103,'第三会议室',12,'0','市场部专用会议室'),
(8,401,'第四会议室',15,'0','公共会议室'),
(9,201,'第五会议室',15,'0','最大会议室'),
(10,601,'第六会议室',12,'0','需要提前三天预定');

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

 

9.有什么问题欢迎留言

目前的项目结构

 

jar包请自行下载,还有Tomcat自己安装好

  • 5
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一身正气z

打赏随心就好

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值