作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
管理员角色包含以下功能:
管理员登录,用户管理,账单管理,挂失记录管理等功能。
学生用户角色包含以下功能:
用户登录,查询消费记录,充值余额,挂失校园卡,个人信息修改等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
HTML+CSS+JavaScript+jsp+mysql
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
运行截图
相关代码
学生管理控制器
@Controller
@RequestMapping("/studentController")
public class StudentController extends BaseController{
private static final Logger logger = Logger.getLogger(StudentController.class);
@Autowired
private StudentService studentService;
/**
* 初始访问
* @param
* @param model
* @return
*/
@RequestMapping(params="goStudent")
public ModelAndView goStudent(HttpServletRequest request){
return new ModelAndView("buss/student");
}
@RequestMapping(params="checkNum")
@ResponseBody
public void checkNum(HttpServletRequest request, HttpServletResponse response, String studentNum) throws Exception {
StudentEntity student = this.studentService.findUniqueByProperty(StudentEntity.class, "studentnum", studentNum);
String flag = "true";
if(student != null){
flag = "false";
}
response.setCharacterEncoding("utf-8");
response.getWriter().write(flag);
}
@RequestMapping(params="save")
@ResponseBody
public AjaxJson save(HttpServletRequest request, HttpServletResponse response, StudentEntity student) throws Exception {
AjaxJson j = new AjaxJson();
j.setMsg("保存成功!");
j.setSuccess(true);
try{
this.studentService.save(student);
}catch(Exception e){
j.setMsg("保存失败!");
j.setSuccess(false);
}
return j;
}
@RequestMapping(params="update")
@ResponseBody
public AjaxJson update(HttpServletRequest request, HttpServletResponse response, StudentEntity student) throws Exception {
AjaxJson j = new AjaxJson();
j.setMsg("更新成功!");
j.setSuccess(true);
try{
// StudentEntity se = this.studentService.get(StudentEntity.class, student.getId());
this.studentService.update(student);
}catch(Exception e){
j.setMsg("更新失败!");
j.setSuccess(false);
}
return j;
}
@RequestMapping(params="delete",method=RequestMethod.POST)
@ResponseBody
public AjaxJson delete(HttpServletRequest request, HttpServletResponse response, String ids) throws Exception {
AjaxJson j = new AjaxJson();
j.setMsg("删除成功!");
j.setSuccess(true);
try{
for(String id:ids.split(",")){
StudentEntity student = this.studentService.get(StudentEntity.class, id);
this.studentService.delete(student);
}
}catch(ConstraintViolationException ce){
ce.printStackTrace();
j.setMsg("删除失败,存在外键引用,请查看其它数据项中是否有与当前数据有关的信息!");
j.setSuccess(false);
}catch(Exception e){
j.setMsg("删除失败!");
j.setSuccess(false);
}
return j;
}
@RequestMapping(params="datagrid")
@ResponseBody
public void datagrid(HttpServletRequest request, HttpServletResponse response,StudentEntity student) throws Exception {
String page = request.getParameter("page");
String rows = request.getParameter("rows");
if(page == null){
page = "0";
}
if(rows == null){
rows = "0";
}
DetachedCriteria condition = DetachedCriteria.forClass(StudentEntity.class);
Pagination<?> pagination = studentService.findPageData(condition,student,Integer.parseInt(page), Integer.parseInt(rows));
JSONObject jobj = new JSONObject();
jobj.put("total", pagination.getTotalCount());
jobj.put("rows", pagination.getDatas());
response.setCharacterEncoding("utf-8");
response.getWriter().write(jobj.toString());
}
}
如果也想学习本系统,下面领取。关注并回复:052jsp