基于javaweb+jsp的饮食营养健康管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)
发布时间
阅读量:
阅读量
基于Java Web + JSR-162框架的智能化饮食管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Layui Ajax
基于JavaServer Pages(Servlet)的基础框架可以选择以下几种:一是结合SSMPattern(如Spring、SpringMVC、MyBatis),二是并结合 Maven(通过pom.xml配置)。另外还可以选择使用 Spring Boot 框架来实现类似的开发功能。
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
<select id="getAllCount" parameterType="java.util.Map" resultType="Integer">
SELECT COUNT(*) FROM `t_user`
<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.FoodMapper">
<resultMap id="BaseResultMap" type="com.demo.vo.Food" >
<result column="id" property="id" />
<result column="food_name" property="foodName" />
<result column="food_type" property="foodType" />
<result column="food_pingjia" property="foodPingjia" />
<result column="food_miaosu" property="foodMiaosu" />
<result column="food_text" property="foodText" />
</resultMap>
for (User user : list) {
if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
request.getRequestDispatcher("register.jsp").forward(request, response);
return;
}
}
User vo = new User();
vo.setUsername(username);
vo.setPassword(password);
//vo.setUserType("普通用户");//需要设置一个默认值
userService.insert(vo);
request.getSession().setAttribute("alert_msg", "注册成功!用户名:[" + username + "]");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
@RequestMapping("authLogout")
public void logout(HttpServletResponse response, HttpServletRequest request) throws IOException {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("loginUser");
if (user != null) {
defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
title: '公告列表',
cols: [
[
{
field: 'noticeName',
title: '标题',
templet: vo => (vo = vo.noticeName) ? '<a href="#" style="color: #009688;">' + vo + '</a>' : '',
event: 'info',
},
{
field: 'noticeText',
title: '内容',
},
{
field: 'noticeType',
title: '类型',
fixed: false, //不固定
maxmin: true,
content: 'shiliaoEditPre?id=' + data.id
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'info') { //详情
layer.open({
type: 2,
area: ['800px', '650px'],
fixed: false, //不固定
maxmin: true,
content: 'shiliaoGet?id=' + data.id
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'LAYTABLE_TIPS') {
layer.alert('Hi,头部工具栏扩展的右侧图标。');
}
});
//头工具栏事件
}
response.sendRedirect("login.jsp");
}
@RequestMapping("authValidationCode")
public void validationCode(HttpServletResponse response, HttpServletRequest request) throws IOException {
String codeChars = "0123456789";// 图形验证码的字符集合,系统将随机从这个字符串中选择一些字符作为验证码
// 获得验证码集合的长度
int charsLength = codeChars.length();
// 下面三条记录是关闭客户端浏览器的缓冲区
// 这三条语句都可以关闭浏览器的缓冲区,但是由于浏览器的版本不同,对这三条语句的支持也不同
// 因此,为了保险起见,建议同时使用这三条语句来关闭浏览器的缓冲区
response.setHeader("ragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 设置图形验证码的长和宽(图形的大小)
int width = 90, height = 20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();// 获得用于输出文字的Graphics对象
Random random = new Random();
g.setColor(getRandomColor(180, 250));// 随机设置要填充的颜色
g.fillRect(0, 0, width, height);// 填充图形背景
// 设置初始字体
g.setFont(new Font("Times New Roman", Font.ITALIC, height));
g.setColor(getRandomColor(120, 180));// 随机设置字体颜色
// 用于保存最后随机生成的验证码
StringBuilder validationCode = new StringBuilder();
*/
@RequestMapping("userDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");
userService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/** * 编辑用户
* * @param response
* @param request
* @throws IOException
*/
@RequestMapping("userEdit")
public void edit(HttpServletResponse response, HttpServletRequest request) throws IOException {
User vo = new User();
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setUsername(Util.decode(request, "username"));
vo.setPassword(Util.decode(request, "password"));
vo.setRealName(Util.decode(request, "realName"));
vo.setUserSex(Util.decode(request, "userSex"));
vo.setUserPhone(Util.decode(request, "userPhone"));
vo.setUserText(Util.decode(request, "userText"));
SELECT <include refid="Base_Column_List" /> FROM `t_notice` WHERE `id` = #{id}
</select>
<!--列表-->
<select id="findAllSplit" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" /> FROM `t_notice`
<where>
<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_notice`
[
{
field: 'username',
title: '用户名',
},
{
field: 'realName',
title: '姓名',
templet: vo => (vo = vo.realName) ? '<a href="#" style="color: #009688;">' + vo + '</a>' : '',
event: 'info',
},
{
field: 'userSex',
title: '性别',
templet: vo => vo.userSex ? vo.userSex : "",
},
{
field: 'userPhone',
title: '手机',
},
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
title: '公告列表',
cols: [
[
{
field: 'noticeName',
title: '标题',
templet: vo => (vo = vo.noticeName) ? '<a href="#" style="color: #009688;">' + vo + '</a>' : '',
event: 'info',
},
{
field: 'noticeText',
title: '内容',
},
{
field: 'noticeType',
title: '类型',
},
{
field: 'createDate',
title: '创建时间',
},
{
align: 'center',
运行环境
Java≥6、Tomcat≥7.0、MySQL≥5.5
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Layui Ajax
基于JSP+Servlet的基础架构 或 包括基于JSP+SSTM技术的框架(支持Spring、SpringMVC和MyBatis等技术) 或 结合使用Maven(通过pom.xml配置) 的框架 或 采用SpringBoot框架
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
实现登录、注册及退出功能的用户管理与维护













全部评论 (0)
还没有任何评论哟~
