基于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…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、订购模块、蛋糕模块的增删改查管理
<th>用户名</th>
<th>姓名</th>
<th>性别</th>
<th>手机</th>
<th>备注</th>
<th>类型</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="vo">
<tr class="index-content-table-td">
<td>${vo.username}</td>
<td>${vo.realName}</td>
<td>${vo.userSex}</td>
<td>${vo.userPhone}</td>
<td title="${vo.userText}">
<c:choose>
<c:when test="${fn:length(vo.userText) > 19}">
<c:out value="${fn:substring(vo.userText, 0, 19)}..."/>
vo.setNoticeType(Util.decode(request, "noticeType"));
vo.setCreateDate(Util.decode(request, "createDate"));
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");
noticeService.delete(Arrays.asList(id));
* @throws IOException
*/
@RequestMapping("noticeEdit")
public void edit(HttpServletResponse response, HttpServletRequest request) throws IOException {
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.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);
<!--批量删除-->
<delete id="doRemoveBatch" parameterType="java.util.Collection">
DELETE FROM `t_shangping` WHERE `id` IN
<foreach collection="list" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<!--修改-->
<update id="doUpdate" parameterType="com.demo.vo.Shangping">
UPDATE `t_shangping`
<set>
<if test ='id != null'>`id` = #{id},</if>
<if test ='shangpingName != null'>`shangping_name` = #{shangpingName},</if>
<if test ='shangpingText != null'>`shangping_text` = #{shangpingText},</if>
<if test ='shangpingJiage != null'>`shangping_jiage` = #{shangpingJiage},</if>
<if test ='shangpingLeimu != null'>`shangping_leimu` = #{shangpingLeimu}</if>
</set>
WHERE `id` = #{id}
</update>
<table class="index-content-table-add">
<tr>
<td width="12%">商品名:</td><td><input class="index-content-table-td-add" type="text" id="cakeName" name="cakeName" value="${vo.cakeName}"/></td>
</tr>
<tr>
<td width="12%">订购人:</td><td><input class="index-content-table-td-add" type="text" id="buyerName" name="buyerName" value="${vo.buyerName}"/></td>
</tr>
<tr>
<td width="12%">性别:</td>
<td>
<input name="buyerSex" type="radio" value="男" ${vo.buyerSex=='男'?'checked':''}/> 男
<input name="buyerSex" type="radio" value="女" ${vo.buyerSex=='女'?'checked':''}/> 女
<input name="buyerSex" type="radio" value="保密" ${vo.buyerSex=='保密'?'checked':''}/> 保密
</td>
</tr>
}
if (document.getElementById("password").value.trim().length == 0) {
alert("密码不能为空!");
return false;
}
if (document.getElementById("realName").value.trim().length == 0) {
alert("姓名不能为空!");
return false;
}
if (document.getElementById("userPhone").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>
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;
}
chLength++;
}
}
return count / chLength > 0.4;
}
/**
</td>
</tr>
<tr>
<td width="12%">电话:</td><td><input class="index-content-table-td-add" type="text" id="buyerPhone" name="buyerPhone" value="${vo.buyerPhone}"/></td>
</tr>
<tr>
<td width="12%">地址:</td><td><input class="index-content-table-td-add" type="text" id="buyerAddress" name="buyerAddress" value="${vo.buyerAddress}"/></td>
</tr>
<tr>
<td width="12%">订购时间:</td><td><input class="index-content-table-td-add" type="text" id="buyTime" name="buyTime" value="${vo.buyTime}"/></td>
</tr>
<tr>
<td width="12%">价格:</td><td><input class="index-content-table-td-add" type="text" id="cakePrice" name="cakePrice" value="${vo.cakePrice}"/></td>
</tr>
</table>
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getUserSex() {
return userSex;
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setShangpingName(Util.decode(request, "shangpingName"));
vo.setShangpingText(Util.decode(request, "shangpingText"));
vo.setShangpingJiage(Util.decode(request, "shangpingJiage"));
vo.setShangpingLeimu(Util.decode(request, "shangpingLeimu"));
shangpingService.update(vo);
this.redirectList(request, response);
}
/**
* 获取蛋糕的详细信息(详情页面与编辑页面要显示该蛋糕的详情)并跳转回页面
*
* @param response
this.cakeName = cakeName;
}
public String getBuyerName() {
return buyerName;
}
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
public String getBuyerSex() {
return buyerSex;
}
public void setBuyerSex(String buyerSex) {
this.buyerSex = buyerSex;
}
public String getBuyerPhone() {
return buyerPhone;
}
@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");
}
/**
* 根据条件查询公告的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
//@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
HttpSession session = request.getSession();
//移除错误提示
session.removeAttribute("alert_msg");
//登录拦截
String uri = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/"));
String[] access = new String[]{"login", "logout", "register", ".css", ".js", ".png", ".jpg", "validationCode"};
for (String action : access) {
if (uri.toLowerCase().contains(action.toLowerCase())) {
return true;
}
}
if (session.getAttribute("loginUser") == null) {
session.setAttribute("alert_msg", "错误:请先登录!");
response.sendRedirect("login.jsp");
return false;
}
return true;
}
//@Override
<if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
${searchColumn} LIKE CONCAT('%',#{keyword},'%') AND
</if>
1=1
</where>
ORDER BY id ASC
<if test="startIndex != null and pageSize != null">
LIMIT #{startIndex},#{pageSize};
</if>
</select>
<!--数量-->
<select id="getAllCount" parameterType="java.util.Map" resultType="Integer">
SELECT COUNT(*) FROM `t_order`
<where>
<if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
g.setFont(new Font(fontNames[random.nextInt(3)], Font.ITALIC, height));
// 随机获得当前验证码的字符
char codeChar = codeChars.charAt(random.nextInt(charsLength));
validationCode.append(codeChar);
// 随机设置当前验证码字符的颜色
g.setColor(getRandomColor(10, 100));
// 在图形上输出验证码字符,x和y都是随机生成的
g.drawString(String.valueOf(codeChar), 16 * i + random.nextInt(7), height - random.nextInt(6));
}
HttpSession session = request.getSession();
session.setMaxInactiveInterval(5 * 60);
// 将验证码保存在session对象中,key为validation_code
session.setAttribute("validationCode", validationCode.toString());
g.dispose();// 关闭Graphics对象
OutputStream os = response.getOutputStream();
ImageIO.write(image, "JPEG", os);// 以JPEG格式向客户端发送图形验证码
}
@RequestMapping("authResetPassword")
public void resetPassword(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
}
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
public String getBuyerSex() {
return buyerSex;
}
public void setBuyerSex(String buyerSex) {
this.buyerSex = buyerSex;
}
public String getBuyerPhone() {
return buyerPhone;
}
public void setBuyerPhone(String buyerPhone) {
this.buyerPhone = buyerPhone;
}
public String getBuyerAddress() {
return buyerAddress;
}
public void setBuyerAddress(String buyerAddress) {