作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
管理员角色包含以下功能:
管理员登录,管理员管理,就医指南管理,科室管理,医生信息管理,预约信息管理,医生排班管理,药品信息管理,床位信息管理,留言管理等功能。
用户角色包含以下功能:
用户主页,就医指南查看,医生排班查看,医生信息查看,用户登录,留言,预约医生,提交预约等功能。
医生角色包含以下功能:
医生角色登录,个人资料修改,预约信息管理等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
HTML+CSS+JavaScript+jsp+mysql
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/login.jsp 登录
运行截图
用户界面
管理端界面
相关代码
管理端控制器
public class AdminAction extends HttpServlet {
/**
* Constructor of the object.
*/
public AdminAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
try{
String method=request.getParameter("method").trim();
AdminBean loginbean = new AdminBean();
HttpSession session = request.getSession();
session.setMaxInactiveInterval(1200);
SystemBean systembean = new SystemBean();
String sysdir = systembean.getDir();
if(method.equals("one")){//admin登录
String username = request.getParameter("username");
String password = request.getParameter("password");String sf = request.getParameter("sf");
if(username == null||username.trim().equals("")){
request.setAttribute("message", "请正确输入用户名!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else if(password == null||password.trim().equals("")){
request.setAttribute("message", "请输入密码!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else{
ComBean cb=new ComBean();
String str=cb.getString("select id from admin where username='"+username+"' and password='"+password+"' and sf='"+sf+"'");
if(str!=null){
session.setAttribute("user", username);session.setAttribute("sf", sf);
request.getRequestDispatcher("admin/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "登录信息错误!");
request.getRequestDispatcher("admin/login.jsp").forward(request, response);
}
}
}
else if(method.equals("editpwd")){//admin edit password
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
String username = (String)session.getAttribute("user");
int flag = loginbean.editPassword(username, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "密码修改成功!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "原始密码错误,请确认权限!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
case Constant.SYSTEM_ERROR:
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response);
break;
}
}
}
else if(method.equals("exit")){//admin exit
session.removeAttribute("user");
session.removeAttribute("sf");
System.gc();
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else if(method.equals("manager")){//add,update manager
String username = request.getParameter("bh").trim();
String password = MD5.MD5(request.getParameter("password").trim());
int flag = loginbean.addManager(username, password, "2", "1");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "该用户名已经存在!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
}
else if(method.equals("delm")){//delete manager
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
int id = Integer.parseInt(request.getParameter("id").trim());
if(id == 1){
request.setAttribute("message", "不能删除原始帐号!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
int flag = loginbean.delManager(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
}
}
}
else if(method.equals("dellog")){//delete login note
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = loginbean.delLog(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除记录成功!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
}
}
}
else{//无参数传入转到错误页面
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
登录控制器
public class LoginAction extends HttpServlet {
/**
* Constructor of the object.
*/
public LoginAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
if(method.equals("PAGEUSERLOGIN")){//登陆页面会员登陆
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
String lastip = request.getRemoteAddr();
int flag = memberBean.memberLogin(username, password, reg_type);
if(flag == Constant.SUCCESS){//登陆成功
String info = memberBean.getLastTimeIP(username);
int flag2 = memberBean.upmemberLogin(username, lastip);
if(flag2 == Constant.SUCCESS){
session.setAttribute("member", username);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
request.getRequestDispatcher("member/index.jsp").forward(request, response);
}
else{
session.setAttribute("member", username);
session.setAttribute("type", reg_type);
session.setAttribute("info", info);
session.setAttribute("message", "登陆成功,登陆信息更新失败!");
request.getRequestDispatcher("member/index.jsp").forward(request, response);
}
}
else if(flag == Constant.NAME_ERROR){//用户名错误
request.setAttribute("reg_user", username);
request.setAttribute("message", "登录信息错误或已经被拉入黑名单!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else if(flag == Constant.PASSWORD_ERROR){//密码错误
request.setAttribute("reg_user", username);
request.setAttribute("message", "登录信息错误或已经被拉入黑名单!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
else if(method.equals("logout")){//从iframe页面退出登陆
session.removeAttribute("member");
session.removeAttribute("type");
request.getRequestDispatcher("login1.jsp").forward(request, response);
}
else if(method.equals("pagelogout")||method.equals("memberexit")){//从网页退出登陆
session.removeAttribute("member");
session.removeAttribute("type");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
用户管理控制器
public class MemberAction extends HttpServlet {
/**
* Constructor of the object.
*/
public MemberAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
/*********************************************
* 会员注册通用(检查用户名 修改密码 reg2.jsp页面跳转)
*********************************************/
if(method.equals("reg2")){//会员注册 reg2.jsp
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
request.setAttribute("username", username);
request.setAttribute("password", password);
request.setAttribute("reg_type", reg_type);
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
if(reg_type.equals("person")){//如果是个人会员
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
else if(reg_type.equals("co")){//如果是会员
request.getRequestDispatcher("coreg.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("checksame")){//检查注册名是否可用
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
request.setAttribute("username", username);
request.setAttribute("message", "恭喜您,这个名字可以使用!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("Editpwd")){//会员修改登陆密码
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
int flag = memberBean.editPassword(member, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "密码修改成功!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "原始密码错误,请确认权限!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.SYSTEM_ERROR:
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
}
}
}
/*********************************************
* 个人会员注册、修改资料
*********************************************/
else if(method.equals("PREG")){//个人会员详细资料
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String type = "person";
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
String lastip = request.getRemoteAddr();
int off = 1;
ComBean cb=new ComBean();
String str=cb.getString("select id from pmember where address='"+address+"'");
if(str==null){
int flag = memberBean.personReg(username, password, type, realname, sex, bir,sheng,city, telphone, email, question, answer, lastip, off,address);
if(flag == Constant.SUCCESS){
List siteList = new SystemBean().getSiteInfo();
String sitename = siteList.get(0).toString();
request.setAttribute("message", "注册成功!恭喜您成为"+sitename+"的注册会员!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
}
else{
request.setAttribute("message", "该身份证已经被注册!");
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
}
else if(method.equals("UPREGINFO")){//个人会员修改资料
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
int flag = memberBean.uppersonReg(member, realname, sex, bir, sheng, city, telphone, email, question, answer,address);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
}
}
else if(method.equals("lostpwd")){
String username=request.getParameter("username");
String question=request.getParameter("question");
String answer=request.getParameter("answer");
String reg_type=request.getParameter("reg_type");
String info=memberBean.returnPwd(username, question, answer, reg_type);
if(info.trim().equals("error")){
request.setAttribute("message", "信息错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "您的新密码为"+info+",请登录后修改!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
如果也想学习本系统,下面领取。关注并回复:028jsp