基于javaweb+jsp的实验室管理系统(JavaWeb MySQL JSP Bootstrap Servlet SSM SpringBoot)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、设备模块、实验室模块、维修模块的增删改查管理
return false;
}
return true;
}
</script>
</html>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>添加维修</title>
<link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<jsp:include page="menu.jsp"/>
* @param request
* @throws IOException
*/
@RequestMapping("userList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
private String keyword;//待模糊查询的关键字
//通过pageNum,pageSize,totalRecord计算得来tatalPage和startIndex,构造方法中将pageNum,pageSize,totalRecord获得
public PageBean(int pageNum, int totalRecord) {
this.pageNum = (pageNum = Math.max(pageNum, 1));
this.pageSize = 10;//默认为10
this.totalRecord = totalRecord;
//totalPage 总页数
if (totalRecord % pageSize == 0) {
//说明整除,正好每页显示pageSize条数据,没有多余一页要显示少于pageSize条数据的
this.totalPage = totalRecord / pageSize;
} else {
//不整除,就要在加一页,来显示多余的数据。
this.totalPage = totalRecord / pageSize + 1;
}
//开始索引
this.startIndex = (pageNum - 1) * pageSize;
<if test ='shebeiName != null'>`shebei_name`,</if>
<if test ='shebeiShiyanshi != null'>`shebei_shiyanshi`,</if>
<if test ='shebeiShuliang != null'>`shebei_shuliang`,</if>
<if test ='shebeiZhuangtai != null'>`shebei_zhuangtai`,</if>
<if test ='shebeiText != null'>`shebei_text`</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test ='id != null'>#{id},</if>
<if test ='shebeiName != null'>#{shebeiName},</if>
<if test ='shebeiShiyanshi != null'>#{shebeiShiyanshi},</if>
<if test ='shebeiShuliang != null'>#{shebeiShuliang},</if>
<if test ='shebeiZhuangtai != null'>#{shebeiZhuangtai},</if>
<if test ='shebeiText != null'>#{shebeiText}</if>
</trim>
</insert>
<!--批量删除-->
<delete id="doRemoveBatch" parameterType="java.util.Collection">
DELETE FROM `t_shebei` WHERE `id` IN
<foreach collection="list" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<!--修改-->
<update id="doUpdate" parameterType="com.demo.vo.Shebei">
}
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
public String getServlet() {
return servlet;
}
public void setServlet(String servlet) {
this.servlet = servlet;
}
</tr>
<tr>
<td width="12%">报修时间:</td><td><input class="index-content-table-td-add" type="text" id="weixiuBaoxiushjjian" name="weixiuBaoxiushjjian" value=""/></td>
</tr>
<tr>
<td width="12%">维修人:</td><td><input class="index-content-table-td-add" type="text" id="weixiuWeixiuren" name="weixiuWeixiuren" value=""/></td>
</tr>
<tr>
<td width="12%">维修时间:</td><td><input class="index-content-table-td-add" type="text" id="weixiuWeixiushijian" name="weixiuWeixiushijian" value=""/></td>
</tr>
</table>
<br>
<br>
<br>
<button type="submit" class="btn btn-rect btn-grad btn-danger btn-sm">提交</button> <button type="button" class="btn btn-rect btn-grad btn-danger btn-sm" onclick="javascript:history.back(-1);">取消</button>
</form>
</div>
</body>
<script type="text/javascript">
//提交之前进行检查,如果return false,则不允许提交
function check() {
if (document.getElementById("weixiuWeixiushijian").value.trim().length == 0) {
alert("维修时间不能为空!");
return false;
}
return true;
}
</script>
</html>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>添加维修</title>
<link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<jsp:include page="menu.jsp"/>
<div class="index-content">
<sql id="Base_Column_List">
`id`,`weixiu_name`,`weixiu_shiyanshi`,`weixiu_baoxiuren`,`weixiu_yuanyin`,`weixiu_zhuangtai`,`weixiu_baoxiushjjian`,`weixiu_weixiuren`,`weixiu_weixiushijian`
</sql>
<!--新增-->
<insert id="doCreate" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.demo.vo.Weixiu">
INSERT INTO `t_weixiu`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test ='id != null'>`id`,</if>
<if test ='weixiuName != null'>`weixiu_name`,</if>
<if test ='weixiuShiyanshi != null'>`weixiu_shiyanshi`,</if>
<if test ='weixiuBaoxiuren != null'>`weixiu_baoxiuren`,</if>
<if test ='weixiuYuanyin != null'>`weixiu_yuanyin`,</if>
<if test ='weixiuZhuangtai != null'>`weixiu_zhuangtai`,</if>
<if test ='weixiuBaoxiushjjian != null'>`weixiu_baoxiushjjian`,</if>
<if test ='weixiuWeixiuren != null'>`weixiu_weixiuren`,</if>
<if test ='weixiuWeixiushijian != null'>`weixiu_weixiushijian`</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test ='id != null'>#{id},</if>
<select id="getAllCount" parameterType="java.util.Map" resultType="Integer">
SELECT COUNT(*) FROM `t_shiyanshi`
<where>
<if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
${searchColumn} LIKE CONCAT('%',#{keyword},'%') AND
</if>
1=1
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.dao.NoticeMapper">
<resultMap id="BaseResultMap" type="com.demo.vo.Notice" >
<result column="id" property="id" />
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test ='id != null'>#{id},</if>
<if test ='username != null'>#{username},</if>
<if test ='password != null'>#{password},</if>
<if test ='realName != null'>#{realName},</if>
<if test ='userSex != null'>#{userSex},</if>
<if test ='userPhone != null'>#{userPhone},</if>
<if test ='userText != null'>#{userText},</if>
<if test ='userType != null'>#{userType}</if>
</trim>
</insert>
<!--批量删除-->
<body>
<jsp:include page="menu.jsp"/>
<div class="index-content">
<div class="index-content-operation">
<a class="info-detail">修改用户</a>
<br>
<br>
</div>
<br>
<form action="userEdit" method="post" onsubmit="return check()">
<input type="hidden" id="id" name="id" value="${vo.id}"/>
<table class="index-content-table-add">
<tr>
<td width="12%">用户名:</td><td><input class="index-content-table-td-add" type="text" id="username" name="username" value="${vo.username}"/></td>
</tr>
<tr>
<td width="12%">密码:</td><td><input class="index-content-table-td-add" type="text" id="password" name="password" value="${vo.password}"/></td>
</tr>
<tr>
<td width="12%">姓名:</td><td><input class="index-content-table-td-add" type="text" id="realName" name="realName" value="${vo.realName}"/></td>
</tr>
}
/**
* 获取设备的详细信息(详情页面与编辑页面要显示该设备的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"shebeiGet", "shebeiEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");//取出主键id
Shebei vo = shebeiService.get(id);
request.getSession().setAttribute("vo", vo);
String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
response.sendRedirect("shebei_" + to + ".jsp");
}
/**
* 根据条件查询设备的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("shebeiList")
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("shiyanshi_list.jsp");
}
}
package com.demo.controller;
import com.demo.util.Util;
import com.demo.service.NoticeService;
import com.demo.vo.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Controller
public class AuthController extends HttpServlet {
@Autowired
private UserService userService;
request.getSession().setAttribute("alert_msg", msg);
request.getRequestDispatcher("reset_password.jsp").forward(request, response);
}
// 返回一个随机颜色(Color对象)
private Color getRandomColor(int minColor, int maxColor) {
Random random = new Random();
// 保存minColor最大不会超过255
if (minColor > 255)
minColor = 255;
// 保存minColor最大不会超过255
if (maxColor > 255)
maxColor = 255;
// 获得红色的随机颜色值
int red = minColor + random.nextInt(maxColor - minColor);
// 获得绿色的随机颜色值
int green = minColor + random.nextInt(maxColor - minColor);
// 获得蓝色的随机颜色值
int blue = minColor + random.nextInt(maxColor - minColor);
return new Color(red, green, blue);
}
}
package com.demo.controller;
noticeService.update(vo);
this.redirectList(request, response);
}
/**
* 获取公告的详细信息(详情页面与编辑页面要显示该公告的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"noticeGet", "noticeEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");//取出主键id
Notice vo = noticeService.get(id);
request.getSession().setAttribute("vo", vo);
String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
response.sendRedirect("notice_" + to + ".jsp");
}