JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
return false;
}
if (document.getElementById("weixiuGuzhang").value.trim().length == 0) {
alert("故障不能为空!");
return false;
}
if (document.getElementById("weixiuFeiyong").value.trim().length == 0) {
alert("维修费用不能为空!");
return false;
}
if (document.getElementById("weixiuDate").value.trim().length == 0) {
alert("维修日期不能为空!");
return false;
}
if (document.getElementById("weixiuRen").value.trim().length == 0) {
alert("维修人不能为空!");
return false;
}
if (document.getElementById("weixiuPhone").value.trim().length == 0) {
alert("维修人电话不能为空!");
return false;
}
return true;
}
</script>
</html>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
</tr>
<tr>
<td width="12%">维修费用:</td><td><input class="index-content-table-td-add" type="text" id="weixiuFeiyong" name="weixiuFeiyong" value="${vo.weixiuFeiyong}"/></td>
</tr>
<tr>
<td width="12%">维修日期:</td><td><input class="index-content-table-td-add" type="text" id="weixiuDate" name="weixiuDate" value="${vo.weixiuDate}"/></td>
</tr>
<tr>
<td width="12%">维修人:</td><td><input class="index-content-table-td-add" type="text" id="weixiuRen" name="weixiuRen" value="${vo.weixiuRen}"/></td>
</tr>
<tr>
<td width="12%">维修人电话:</td><td><input class="index-content-table-td-add" type="text" id="weixiuPhone" name="weixiuPhone" value="${vo.weixiuPhone}"/></td>
</tr>
<tr>
<td width="12%">状态:</td>
<td width="12%">使用部门:</td><td><input class="index-content-table-td-add" type="text" id="shebeiDept" name="shebeiDept" value="${vo.shebeiDept}"/></td>
</tr>
<tr>
<td width="12%">状态:</td>
<td>
<input name="shebeiStatus" type="radio" value="正常" ${vo.shebeiStatus=='正常'?'checked':''}/> 正常
<input name="shebeiStatus" type="radio" value="故障" ${vo.shebeiStatus=='故障'?'checked':''}/> 故障
<input name="shebeiStatus" type="radio" value="已报废" ${vo.shebeiStatus=='已报废'?'checked':''}/> 已报废
</td>
</tr>
</table>
<br>
<br>
<br>
<button type="submit" class="btn btn-pill btn-danger btn-sm">提交</button> <button type="button" class="btn btn-pill btn-success btn-sm" onclick="javascript:history.back(-1);">取消</button>
</form>
</div>
/**
* 维修模块的Servlet控制层,负责接收页面传过来的请求参数,根据action参数的值来确定页面要执行的具体操作<br>
* 而后再调用WeixiuService业务层的方法来处理具体的业务,最后将处理完成的结果返回或跳转至相应页面
*/
//@WebServlet("/WeixiuServlet")
public class WeixiuServlet extends HttpServlet {
/**
* 处理Post请求
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (rs.next()) {
vo = new User();
vo.setId(rs.getLong("id"));
vo.setUsername(rs.getString("username"));
vo.setPassword(rs.getString("password"));
vo.setRealName(rs.getString("real_name"));
vo.setUserSex(rs.getString("user_sex"));
vo.setUserPhone(rs.getString("user_phone"));
vo.setUserText(rs.getString("user_text"));
vo.setUserType(rs.getString("user_type"));
}
c.close();
} catch (Exception e) {
e.printStackTrace();
}
return vo;
}
//@Override
public Map<String, Object> list(Map<String, Object> params) {
List<User> list = new ArrayList();
int totalCount = 0;
String condition = "";
String sqlList;
if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
<td>
<input name="weixiuStatus" type="radio" value="已修好" ${vo.weixiuStatus=='已修好'?'checked':''}/> 已修好
<input name="weixiuStatus" type="radio" value="待维修" ${vo.weixiuStatus=='待维修'?'checked':''}/> 待维修
</td>
</tr>
<tr>
<td width="12%">备注:</td><td><textarea id="weixiuText" name="weixiuText" style="width: 60%; height: 100px;padding: 0px 17px;" placeholder="请输入内容......">${vo.weixiuText}</textarea></td>
</tr>
</table>
<br>
<br>
<br>
<button type="submit" class="btn btn-pill btn-danger btn-sm">提交</button> <button type="button" class="btn btn-pill btn-success btn-sm" onclick="javascript:history.back(-1);">取消</button>
</form>
</div>
alert("生产厂家不能为空!");
return false;
}
if (document.getElementById("shebeiIndate").value.trim().length == 0) {
alert("采购日期不能为空!");
return false;
}
if (document.getElementById("shebeiInprice").value.trim().length == 0) {
alert("采购价格不能为空!");
return false;
}
if (document.getElementById("shebeiDept").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>
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS);
}
/**
* 判断字符串是否是乱码
*
* @param strName
* @return
*/
public static boolean isMessyCode(String strName) {
java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\s*|\t*|\r*|\n*");
java.util.regex.Matcher m = p.matcher(strName);
String after = m.replaceAll("");
String temp = after.replaceAll("\\p{P}", "");
char[] ch = temp.trim().toCharArray();
float chLength = 0;
float count = 0;
for (int i = 0; i < ch.length; i++) {
char c = ch[i];
if (!Character.isLetterOrDigit(c)) {
if (!isChinese(c)) {
count = count + 1;
String sql = "delete from `t_user` where id = " + id;
s.execute(sql);
s.close();
c.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
//@Override
public User get(Serializable id) {
User vo = null;
try {
Connection c = Util.getConnection();
}
if (document.getElementById("shebeiNo").value.trim().length == 0) {
alert("编号不能为空!");
return false;
}
if (document.getElementById("shebeiType").value.trim().length == 0) {
alert("类型不能为空!");
return false;
}
if (document.getElementById("shebeiCangjia").value.trim().length == 0) {
alert("生产厂家不能为空!");
return false;
}
if (document.getElementById("shebeiIndate").value.trim().length == 0) {
alert("采购日期不能为空!");
return false;
}
if (document.getElementById("shebeiInprice").value.trim().length == 0) {
alert("采购价格不能为空!");
<tr>
<td width="12%">维修人:</td><td><input class="index-content-table-td-add" type="text" id="weixiuRen" name="weixiuRen" value=""/></td>
</tr>
<tr>
<td width="12%">维修人电话:</td><td><input class="index-content-table-td-add" type="text" id="weixiuPhone" name="weixiuPhone" value=""/></td>
</tr>
<tr>
<td width="12%">状态:</td>
<td>
<input name="weixiuStatus" type="radio" value="已修好" checked="checked"/> 已修好
<input name="weixiuStatus" type="radio" value="待维修"/> 待维修
</td>
</tr>
<tr>
<td width="12%">备注:</td><td><textarea id="weixiuText" name="weixiuText" style="width: 60%; height: 100px;padding: 0px 17px;" placeholder="请输入内容......"></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<br>
<button type="submit" class="btn btn-pill btn-danger btn-sm">提交</button> <button type="button" class="btn btn-pill btn-success btn-sm" onclick="javascript:history.back(-1);">取消</button>
</form>
</div>
</body>
<script type="text/javascript">
//提交之前进行检查,如果return false,则不允许提交
function check() {
//根据ID获取值
if (document.getElementById("shebeiName").value.trim().length == 0) {
alert("名称不能为空!");
return false;
}
if (document.getElementById("shebeiNo").value.trim().length == 0) {
alert("编号不能为空!");
return false;
import com.demo.util.Util;
import com.demo.service.NoticeService;
import com.demo.service.impl.NoticeServiceImpl;
import com.demo.vo.Notice;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 公告模块的Servlet控制层,负责接收页面传过来的请求参数,根据action参数的值来确定页面要执行的具体操作<br>
* 而后再调用NoticeService业务层的方法来处理具体的业务,最后将处理完成的结果返回或跳转至相应页面
*/
//@WebServlet("/NoticeServlet")
public class NoticeServlet extends HttpServlet {
<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">
<div class="index-content-operation">
<a class="info-detail">修改设备</a>
<br>
<br>
</div>
<br>
<form action="ShebeiServlet?action=edit" 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="shebeiName" name="shebeiName" value="${vo.shebeiName}"/></td>
</tr>
<tr>
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//过滤编码
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String action = Util.decode(request, "action");
if ("add".equals(action)) {//增加
Notice vo = new Notice();
//取出页面传进来的各个数据,并设置到Notice对象的属性里
vo.setNoticeName(Util.decode(request, "noticeName"));
vo.setNoticeText(Util.decode(request, "noticeText"));
vo.setNoticeType(Util.decode(request, "noticeType"));
vo.setCreateDate(Util.decode(request, "createDate"));
NoticeService noticeService = new NoticeServiceImpl();
//调用Service层增加方法(add),增加记录
noticeService.add(vo);
this.redirectList(request, response);
} else if ("delete".equals(action)) {//删除
//取出表要删除的公告记录的主键
long id = Long.parseLong(Util.decode(request, "id"));
NoticeService noticeService = new NoticeServiceImpl();
<%@ 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">
<div class="index-content-operation">
<a class="info-detail">修改用户</a>
<br>
<br>
</div>
<br>
<form action="UserServlet?action=edit" method="post" onsubmit="return check()">
<input type="hidden" id="id" name="id" value="${vo.id}"/>
vo.setNoticeType(Util.decode(request, "noticeType"));
vo.setCreateDate(Util.decode(request, "createDate"));
NoticeService noticeService = new NoticeServiceImpl();
//调用Service层增加方法(add),增加记录
noticeService.add(vo);
this.redirectList(request, response);
} else if ("delete".equals(action)) {//删除
//取出表要删除的公告记录的主键
long id = Long.parseLong(Util.decode(request, "id"));
NoticeService noticeService = new NoticeServiceImpl();
//调用Service层删除方法(delete),将对应的记录删除
noticeService.delete(id);
this.redirectList(request, response);
} else if ("edit".equals(action)) {//修改
//取出页面传进来的各个数据,并设置到Notice对象的属性里
Notice vo = new Notice();
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setNoticeName(Util.decode(request, "noticeName"));
vo.setNoticeText(Util.decode(request, "noticeText"));
vo.setNoticeType(Util.decode(request, "noticeType"));
vo.setCreateDate(Util.decode(request, "createDate"));
NoticeService noticeService = new NoticeServiceImpl();
//调用Service层更新方法(update),更新记录
noticeService.update(vo);
this.redirectList(request, response);
} else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
NoticeService noticeService = new NoticeServiceImpl();
Notice vo = noticeService.get(id);
while (rs.next()) {
Notice vo = new Notice();
vo.setId(rs.getLong("id"));
vo.setNoticeName(rs.getString("notice_name"));
vo.setNoticeText(rs.getString("notice_text"));
vo.setNoticeType(rs.getString("notice_type"));
vo.setCreateDate(rs.getString("create_date"));
list.add(vo);
}
String sqlCount = "select count(*) from `t_notice` where 1=1 " + condition;
ps = c.prepareStatement(sqlCount);
rs = ps.executeQuery();
if (rs.next()) {
totalCount = rs.getInt(1);
}
rs.close();
ps.close();
c.close();
} catch (Exception e) {
e.printStackTrace();
}
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = Util.decode(request, "searchColumn");
String keyword = Util.decode(request, "keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
NoticeService noticeService = new NoticeServiceImpl();
Map<String, Object> map = noticeService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = Util.decode(request, "pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
} catch (Exception e) {
e.printStackTrace();
}
}
//@Override
public boolean delete(long id) {
try {
Connection c = Util.getConnection();
Statement s = c.createStatement();
String sql = "delete from `t_shebei` where id = " + id;
s.execute(sql);
s.close();
c.close();
return true;
return false;
}
if (document.getElementById("shebeiDept").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">
<div class="index-content-operation">
<a class="info-detail">修改用户</a>
<br>
<br>
</div>
import java.text.SimpleDateFormat;
/**
* 该方法为通用的工具类,放置一些共用的方法
*/
public class Util {
public static String DBDRIVER = "com.mysql.jdbc.Driver";
public static String DBURL = "jdbc:mysql://localhost:3306/project_000000000000?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false&allowPublicKeyRetrieval=true";
public static String DBUSER = "root";
public static String PASSWORD = "123456";
/**
* 取得数据库连接对象
*
* @return 如果连接成功则返回连接对象,如果连接失败返回null
*/
public static Connection getConnection() throws Exception {
Class.forName(DBDRIVER);
return DriverManager.getConnection(DBURL, DBUSER, PASSWORD);
}
/**
* 测试连接是否成功
运行环境
Java≥6、Tomcat≥7.0、MySQL≥5.5
开发工具
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…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、设备模块、维修模块的增删改查管理