JavaWeb开发基于ssm的校园服务系统(实例详解)

 更新时间:2020年02月04日 10:42:59   作者:彭祥.  
这篇文章主要介绍了JavaWeb开发基于ssm的校园服务系统,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下

利用Javaweb开发的一个校园服务系统,通过发布自己的任务并设置悬赏金额,有些类似于赏金猎人,在这里分享给大家,有需要可以联系我:2186527424:

<?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.ssm.mapper.UserMapper" >
 <resultMap id="BaseResultMap" type="com.ssm.po.User" >
 <id column="stuid" property="stuid" jdbcType="INTEGER" />
 <result column="studentid" property="studentid" jdbcType="VARCHAR" />
 <result column="password" property="password" jdbcType="VARCHAR" />
 <result column="schoolid" property="schoolid" jdbcType="INTEGER" />
 <result column="sex" property="sex" jdbcType="INTEGER" />
 <result column="name" property="name" jdbcType="VARCHAR" />
 <result column="registertime" property="registertime" jdbcType="TIMESTAMP" />
 <result column="money" property="money" jdbcType="DOUBLE" />
 <result column="state" property="state" jdbcType="INTEGER" />
 </resultMap>
 <sql id="Base_Column_List" >
 stuid, studentid, password, schoolid, sex, name, registertime, money, state
 </sql>
 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
 select 
 <include refid="Base_Column_List" />
 from user
 where stuid = #{stuid,jdbcType=INTEGER}
 </select>
 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
 delete from user
 where stuid = #{stuid,jdbcType=INTEGER}
 </delete>
 <insert id="insert" parameterType="com.ssm.po.User" >
 insert into user (stuid, studentid, password, 
  schoolid, sex, name, 
  registertime, money, state
  )
 values (#{stuid,jdbcType=INTEGER}, #{studentid,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
  #{schoolid,jdbcType=INTEGER}, #{sex,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
  #{registertime,jdbcType=TIMESTAMP}, #{money,jdbcType=DOUBLE}, #{state,jdbcType=INTEGER}
  )
 </insert>
 <insert id="insertSelective" parameterType="com.ssm.po.User" >
 insert into user
 <trim prefix="(" suffix=")" suffixOverrides="," >
  <if test="stuid != null" >
  stuid,
  </if>
  <if test="studentid != null" >
  studentid,
  </if>
  <if test="password != null" >
  password,
  </if>
  <if test="schoolid != null" >
  schoolid,
  </if>
  <if test="sex != null" >
  sex,
  </if>
  <if test="name != null" >
  name,
  </if>
  <if test="registertime != null" >
  registertime,
  </if>
  <if test="money != null" >
  money,
  </if>
  <if test="state != null" >
  state,
  </if>
 </trim>
 <trim prefix="values (" suffix=")" suffixOverrides="," >
  <if test="stuid != null" >
  #{stuid,jdbcType=INTEGER},
  </if>
  <if test="studentid != null" >
  #{studentid,jdbcType=VARCHAR},
  </if>
  <if test="password != null" >
  #{password,jdbcType=VARCHAR},
  </if>
  <if test="schoolid != null" >
  #{schoolid,jdbcType=INTEGER},
  </if>
  <if test="sex != null" >
  #{sex,jdbcType=INTEGER},
  </if>
  <if test="name != null" >
  #{name,jdbcType=VARCHAR},
  </if>
  <if test="registertime != null" >
  #{registertime,jdbcType=TIMESTAMP},
  </if>
  <if test="money != null" >
  #{money,jdbcType=DOUBLE},
  </if>
  <if test="state != null" >
  #{state,jdbcType=INTEGER},
  </if>
 </trim>
 </insert>
 <update id="updateByPrimaryKeySelective" parameterType="com.ssm.po.User" >
 update user
 <set >
  <if test="studentid != null" >
  studentid = #{studentid,jdbcType=VARCHAR},
  </if>
  <if test="password != null" >
  password = #{password,jdbcType=VARCHAR},
  </if>
  <if test="schoolid != null" >
  schoolid = #{schoolid,jdbcType=INTEGER},
  </if>
  <if test="sex != null" >
  sex = #{sex,jdbcType=INTEGER},
  </if>
  <if test="name != null" >
  name = #{name,jdbcType=VARCHAR},
  </if>
  <if test="registertime != null" >
  registertime = #{registertime,jdbcType=TIMESTAMP},
  </if>
  <if test="money != null" >
  money = #{money,jdbcType=DOUBLE},
  </if>
  <if test="state != null" >
  state = #{state,jdbcType=INTEGER},
  </if>
 </set>
 where stuid = #{stuid,jdbcType=INTEGER}
 </update>
 <update id="updateByPrimaryKey" parameterType="com.ssm.po.User" >
 update user
 set studentid = #{studentid,jdbcType=VARCHAR},
  password = #{password,jdbcType=VARCHAR},
  schoolid = #{schoolid,jdbcType=INTEGER},
  sex = #{sex,jdbcType=INTEGER},
  name = #{name,jdbcType=VARCHAR},
  registertime = #{registertime,jdbcType=TIMESTAMP},
  money = #{money,jdbcType=DOUBLE},
  state = #{state,jdbcType=INTEGER}
 where stuid = #{stuid,jdbcType=INTEGER}
 </update>
 <!-- 根据账号或昵称查找返回user -->
 <select id="selectByLikeNameAccount" resultMap="BaseResultMap" >
 SELECT 
 <include refid="Base_Column_List" /> 
 from `user` WHERE CONCAT(studentid,name) LIKE #{words,jdbcType=VARCHAR} 
 </select>
 <!-- 查找账号个数 -->
 <select id="selectAccountCount" resultType="java.lang.Integer" >
 SELECT COUNT(*) FROM `user` WHERE studentid = #{account,jdbcType=VARCHAR};
 </select>
 <!-- 根据账号查找返回user -->
 <select id="selectUserByAccount" resultMap="BaseResultMap" >
 SELECT <include refid="Base_Column_List" /> FROM `user` WHERE studentid = #{account,jdbcType=VARCHAR};
 </select>
</mapper>

注销登录界面

package com.ssm.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import com.ssm.util.JsonUtil;
import com.ssm.po.School;
import com.ssm.po.User;
import com.ssm.service.SchoolService;
import com.ssm.service.UserService;
/**
 * 注销登录*
 * 异步读取院校列表*
 * 读取一个用户信息*
 * @author 
 *
 */
@Controller
@SessionAttributes({ "nowuser","nowadmin"})
@RequestMapping(value = "common/")
public class CommonController {
 @Resource(name = "schoolService")
 public SchoolService schoolService;
 
 @Resource(name = "userService")
 public UserService userService;
 
 // 注销
 @RequestMapping("logout.do")
 public String logout(HttpServletRequest request, Model model) {
 model.addAttribute("msg", "已退出");
 request.getSession(false).removeAttribute("nowuser");
 request.getSession(false).removeAttribute("nowadmin");
 return "login";
 }
 
 @RequestMapping("getallschools.do")
 public void getallschools(HttpServletResponse response) throws IOException{
 System.out.println("000000000000000000000000000000000");
 List<School> list = schoolService.getAllSchoolsNoState();
 response.setCharacterEncoding("UTF-8");
 response.setContentType("text/html");
 String list_String = JsonUtil.list2json(list);
 PrintWriter out = response.getWriter();
 out.println(list_String);
 out.flush();
 out.close();
 }
 
 @RequestMapping("getuser.do")
 public String getuser(String stuidstr,HttpServletRequest request,Model model) {
 int stuid = 0;
 try {
 stuid = Integer.parseInt(stuidstr);
 } catch (Exception e) {
 model.addAttribute("msg", "出现错误");
 return "userInfo";
 }
 if (stuid==0) {
 model.addAttribute("msg", "出现错误");
 return "userInfo";
 }
 User user = userService.getByUid(stuid);
 model.addAttribute("theuser", user);
 return "userInfo";
 }
}

用户界面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
 String path = request.getContextPath();
 String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
 + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" rel="external nofollow" >
<title>个人中心</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="<%=basePath%>layui/css/layui.css" rel="external nofollow" >
<c:if test="${empty nowuser }">
 <script type="text/javascript">
 alert("请先登录");
 window.location.href="<%=basePath%>login.jsp" rel="external nofollow" ; 
 </script>
</c:if>
</head>
<body class="layui-layout-body">
 <div class="layui-layout layui-layout-admin">
 <div class="layui-header">
 <div class="layui-logo">校园即时服务平台</div>
 <!-- 头部区域(可配合layui已有的水平导航) -->
 <ul class="layui-nav layui-layout-left">
 <li class="layui-nav-item"><a href="">任务中心</a></li>
 <li class="layui-nav-item"><a href="userIndex.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" >个人中心</a></li>
 </ul>
 <ul class="layui-nav layui-layout-right">
 <li class="layui-nav-item"><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
  ${nowuser.name } </a>
  <dl class="layui-nav-child">
  <dd>
  <a href="userIndex.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" >个人信息</a>
  </dd>
  <dd>
  <a href="userUpdate.jsp" rel="external nofollow" rel="external nofollow" >资料修改</a>
  </dd>
  <dd>
  <a href="userPassword.jsp" rel="external nofollow" rel="external nofollow" >安全设置</a>
  </dd>
  </dl></li>
 <li class="layui-nav-item"><a href="common/logout.do" rel="external nofollow" >退了</a></li>
 </ul>
 </div>
 <div class="layui-side layui-bg-black">
 <div class="layui-side-scroll">
 <!-- 左侧导航区域(可配合layui已有的垂直导航) -->
 <ul class="layui-nav layui-nav-tree" lay-filter="test">
  <li class="layui-nav-item"><a href="">校园即时服务平台</a></li>
  <li class="layui-nav-item layui-nav-itemed"><a
  href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" >任务管理</a>
  <dl class="layui-nav-child">
  <dd>
  <a href="task/getusertask.do" rel="external nofollow" >已发布任务</a>
  </dd>
  <dd>
  <a href="task/getuseratask.do" rel="external nofollow" >已接受任务</a>
  </dd>
  <dd>
  <a href="userNewtask.jsp" rel="external nofollow" >发布新任务</a>
  </dd>
  </dl></li>
  <li class="layui-nav-item layui-nav-itemed"><a class=""
  href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" >个人中心</a>
  <dl class="layui-nav-child">
  <dd class="layui-this">
  <a href="userIndex.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" >个人信息</a>
  </dd>
  <dd>
  <a href="userUpdate.jsp" rel="external nofollow" rel="external nofollow" >资料修改</a>
  </dd>
  <dd>
  <a href="userPassword.jsp" rel="external nofollow" rel="external nofollow" >安全设置</a>
  </dd>
  </dl></li>
 </ul>
 </div>
 </div>
 <!-- 内容主体区域-->
 <div class="layui-body">
 <div style="padding: 30px;" class="layui-fluid">
 <div class="layui-row">
  <div class="layui-col-md12">
  <span class="layui-badge-dot"></span> <span
  class="layui-badge-dot layui-bg-orange"></span> <span
  class="layui-badge-dot layui-bg-green"></span> <span
  class="layui-badge-dot layui-bg-cyan"></span> <span
  class="layui-badge-dot layui-bg-blue"></span> <span
  class="layui-badge-dot layui-bg-black"></span> <span
  class="layui-badge-dot layui-bg-gray"></span>
  <fieldset class="layui-elem-field layui-field-title"
  style="margin-top: 30px;">
  <legend>个人信息</legend>
  </fieldset>
  </div>
 </div>
 <div class="layui-row">
  <div class="layui-col-md1">&nbsp;</div>
  <div class="layui-col-md10">
  <fieldset class="layui-elem-field">
  <legend>信息</legend>
  <!-- <div class="layui-field-box">-->
  <table class="layui-table" lay-size="lg" lay-skin="line"
  style="margin-bottom: 0px;">
  <colgroup>
   <col width="150">
   <col width="200">
   <col>
  </colgroup>
  <thead>
   <tr>
   <th>&nbsp;</th>
   <th>&nbsp;</th>
   </tr>
  </thead>
  <tbody>
   <tr>
   <td>用户编号</td>
   <td>${nowuser.stuid }</td>
   </tr>
   <tr>
   <td>用户学号</td>
   <td>${nowuser.studentid }</td>
   </tr>
   <tr>
   <td>用户姓名</td>
   <td>${nowuser.name }</td>
   </tr>
   <tr>
   <td>学校编号</td>
   <td>${nowuser.schoolid }</td>
   </tr>
   <tr>
   <td>用户性别</td>
   <td><c:if test="${nowuser.sex==0 }">
   男
    </c:if> <c:if test="${nowuser.sex!=0 }">
   女
    </c:if></td>
   </tr>
   <tr>
   <td>注册时间</td>
   <td><fmt:formatDate value="${nowuser.registertime }"
   pattern=" yyyy-MM-dd HH:mm:ss" /></td>
   </tr>
   <tr>
   <td>用户余额</td>
   <td>${nowuser.money }</td>
   </tr>
   <tr>
   <td>用户状态</td>
   <td><c:if test="${nowuser.state==0 }">
   正常
    </c:if> <c:if test="${nowuser.state!=0 }">
   被限制
    </c:if></td>
   </tr>
  </tbody>
  </table>
  <!--</div>-->
  </fieldset>
  </div>
  <div class="layui-col-md1">&nbsp;</div>
 </div>
 </div>
 </div>
 <c:if test="${!empty msg }">
 <script type="text/javascript">
 alert("${msg }");
 </script>
 </c:if>
 <div class="layui-footer">
 <!-- 底部固定区域 -->
 © - 校园即时服务平台办公电话:6666666
 </div>
 </div>
 <script src="${pageContext.request.contextPath }/layui/layui.all.js"></script>
 <script>
 //JavaScript代码区域
 layui.use('element', function() {
 var element = layui.element;
 //监听导航点击
 element.on('nav(test)', function(elem) {
 //console.log(elem)
 layer.msg(elem.text());
 });
 });
 </script>
</body>
</html>

总结

以上所述是小编给大家介绍的JavaWeb开发基于ssm的校园服务系统,希望对大家有所帮助!

相关文章

  • 深入分析Comparable与Comparator及Clonable三个Java接口

    深入分析Comparable与Comparator及Clonable三个Java接口

    接口不是类,而是对类的一组需求描述,这些类要遵从接口描述的统一格式进行定义,这篇文章主要为大家详细介绍了Java的Comparable,Comparator和Cloneable的接口,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助
    2022-05-05
  • 使用springboot 获取控制器参数的几种方法小结

    使用springboot 获取控制器参数的几种方法小结

    这篇文章主要介绍了使用springboot 获取控制器参数的几种方法小结,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-12-12
  • Java分形绘制山脉模型

    Java分形绘制山脉模型

    这篇文章主要为大家详细介绍了Java分形绘制山脉模型,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-01-01
  • Java数据敏感词转换成符号的方法详解

    Java数据敏感词转换成符号的方法详解

    在某个论坛下用户可以随意留言,为了防止不法分子在网上任意冲浪,需要对一些敏感词汇进行一些校验,所以这篇文章给大家介绍了Java数据敏感词转换成符号的方法,需要的朋友可以参考下
    2024-03-03
  • Java selenium处理极验滑动验证码示例

    Java selenium处理极验滑动验证码示例

    本篇文章主要介绍了Java selenium处理极验滑动验证码示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-10-10
  • maven工程中jar包瘦身的五种方法

    maven工程中jar包瘦身的五种方法

    这篇文章主要介绍了maven工程中jar包瘦身的五种方法,帮助大家更好的理解和使用maven,感兴趣的朋友可以了解下
    2021-02-02
  • 详解mybatis通过mapper接口加载映射文件

    详解mybatis通过mapper接口加载映射文件

    本篇文章主要介绍了mybatis通过mapper接口加载映射文件 ,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-08-08
  • SpringMVC的概念以及快速入门示例

    SpringMVC的概念以及快速入门示例

    这篇文章主要介绍了SpringMVC的概念以及快速入门示例,SpringMVC 已经成为目前最主流的MVC框架之一,它通过一套注解,让一个简单的 Java 类成为处理请求的控制器,而无须实现任何接口,需要的朋友可以参考下
    2023-05-05
  • 使用vue3.x+vite+element-ui+vue-router+vuex+axios搭建项目

    使用vue3.x+vite+element-ui+vue-router+vuex+axios搭建项目

    因为vue3出了一段时间了,element也出了基于vue3.x版本的element-plus,这篇文章就拿他们搭建一个项目,希望能给你带来帮助
    2021-08-08
  • 详解Java字节码编程之非常好用的javassist

    详解Java字节码编程之非常好用的javassist

    这篇文章主要介绍了详解Java字节码编程之非常好用的javassist,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-04-04

最新评论