基于javaweb的医院管理系统(java+javaweb+jdbc+mysql+lw)

基于javaweb的医院管理系统(java+javaweb+jdbc+mysql+lw)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的医院管理系统(java+javaweb+jdbc+mysql+lw)_第1张图片

基于javaweb的医院管理系统(java+javaweb+jdbc+mysql+lw)_第2张图片

基于javaweb的医院管理系统(java+javaweb+jdbc+mysql+lw)_第3张图片

基于javaweb的医院管理系统(java+javaweb+jdbc+Mysql+lw)

功能介绍:

登录、注册、用户/管理员(角色)、用户信息管理、科系信息管理、查看所有科系、新增科系信息、删除指定科系、修改科系信息、病房信息管理、病人信息管理、医生类型管理、病人手术管理

登录服务类:

public class LoginServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

request.setCharacterEncoding(“utf-8”);

String username = request.getParameter(“username”);

String password = request.getParameter(“password”);

String level = null;

//实例化UserDao对象

UserDao userDao = new UserDao();

User user = userDao.login(username, password);

//判断是否登录成功

if(user != null){//成功

level = user.getLevel();

//判断权限

if(level.equals(“用户”)){

//将用户对象放到session中

request.getSession().setAttribute(“user”, user);

//转发到user.jsp中

request.getRequestDispatcher(“user.jsp”).forward(request, response);

else{

//将管理员对象放到session中

request.getSession().setAttribute(“admin”, user);

//转发到admin.jsp中

request.getRequestDispatcher(“admin.jsp”).forward(request, response);

}else {

//失败

request.setAttribute(“info”," 错误:用户名或密码错误!");

request.getRequestDispatcher(“message.jsp”).forward(request, response);

用户管理控制层:

public class UserExitServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//获取Session

HttpSession session = request.getSession();

session.invalidate();

//转发到login.html页面

response.sendRedirect(“login.html”);

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

管理员服务类:

public class AdminDao extends HttpServlet {

private static final long serialVersionUID = 1L;

private String action;//存储操作描述

//接收请求

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

request.setCharacterEncoding(“utf-8”);

action = request.getParameter(“action”);

//判断所执行操作

switch (action) {

//用户操作

case “query_all_user”:

query_all_user(request, response);break;

case “insert_user”:

insert_user(request,response);break;

case “delete_user”:

delete_user(request, response);break;

case “alter_user”:

alter_user(request, response);break;

//系别操作

case “query_all_department”:

query_all_department(request, response);break;

case “insert_department”:

insert_department(request, response);break;

case “delete_department”:

delete_department(request, response);break;

case “alter_department”:

alter_department(request, response);break;

//病房操作

case “query_all_class”:

query_all_class(request, response);break;

case “insert_class”:

insert_class(request, response);break;

case “delete_class”:

delete_class(request, response);break;

case “alter_class”:

alter_class(request, response);break;

//病人操作

case “query_all_student”:

query_all_student(request, response);break;

case “insert_student”:

insert_student(request, response);break;

case “delete_student”:

delete_student(request, response);break;

case “alter_student”:

alter_student(request, response);break;

//医生操作

case “query_all_course”:

query_all_course(request, response);break;

case “insert_course”:

insert_course(request, response);break;

case “delete_course”:

delete_course(request, response);break;

case “alter_course”:

alter_course(request, response);break;

//手术操作

case “query_all_sc”:

query_all_sc(request, response);break;

case “insert_sc”:

insert_sc(request, response);break;

case “delete_sc”:

delete_sc(request, response);break;

case “alter_sc”:

alter_sc(request, response);break;

default:

break;

/-------------------------------- 用户 -----------------------------------/

//查询所有用户

protected void query_all_user(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType(“text/html;charset=utf-8”);

UserDao userDao = new UserDao();

ArrayList results = userDao.query_all_user();

PrintWriter out = response.getWriter();

//输出结果

你可能感兴趣的:(java,spring,boot,mysql)