环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
Jdbc+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload等等
用户管理控制层:
@Controller @RequestMapping("/user") public class UserController { @Resource private IUserService userService; @ResponseBody @RequestMapping("/login") public String toIndex(User user,HttpSession session){ String account=user.getAccount(); user=userService.userLogin(user.getAccount(),user.getPwd()); if(user!=null){ List
系统管理控制层:
@Controller @RequestMapping("/sys") public class SysController { @Resource private IUserService userService; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @ResponseBody @RequestMapping("/loginAdmin") public String toIndex(Admin admin,HttpSession session){ admin=userService.adminLogin(admin.getName(),admin.getPwd()); if(admin!=null){ session.setAttribute("lastLoginTime", admin.getLastlogintime()); session.setAttribute("account", "123"); userService.setTime(df.format(new Date())); return "true"; }else{ return "false"; } } @RequestMapping("/ForwardAdmin") public String loginForward(HttpSession session){ List> countUserList=userService.countUser(); session.setAttribute("countUser",countUserList); List > countTeachList=userService.countTeach(); session.setAttribute("countTeach",countTeachList); List > countApparatusList=userService.countApparatus(); session.setAttribute("countApparatus",countApparatusList); return "sys/main"; } @RequestMapping("/userTable") public String userTable(HttpSession session){ List > findUserList=userService.findUser(); session.setAttribute("findUserList",findUserList); return "sys/userTable"; } @RequestMapping("/teachTable") public String teachTable(HttpSession session){ List > findUserList=userService.teachTable(); session.setAttribute("findTeachList",findUserList); return "sys/teachTable"; } @RequestMapping("/apparatusTable") public String apparatusTable(HttpSession session){ List > findUserList=userService.apparatusTable(); session.setAttribute("findApparatusList",findUserList); return "sys/apparatusTable"; } @RequestMapping("/exit") public String exit(HttpSession session){ session.invalidate(); return "login"; } @ResponseBody @RequestMapping("/getSex") public List getSex(){ List list=userService.getSex(); return list; } @ResponseBody @RequestMapping("/delUser") public String delUser(Integer id){ userService.delUser(id); return "true"; } @ResponseBody @RequestMapping("/delTeach") public String delTeach(Integer id){ userService.delTeach(id); return "true"; } @ResponseBody @RequestMapping("/delApp") public String delApp(Integer id){ userService.delApp(id); return "true"; } @RequestMapping("/upUser") public String upUser(Integer id,String account,Integer sex,Integer age,String name,String pwd,String tel,String address,HttpSession session){ List list=new ArrayList(); list.add(id); list.add(account); list.add(sex); list.add(age); list.add(name); list.add(pwd); list.add(tel); list.add(address); session.setAttribute("upList", list); return "sys/upUser"; } @RequestMapping("/upTeach") public String upTeach(Integer id,String tname,Integer cid,String ttel,String taddress,HttpSession session){ List list=new ArrayList(); list.add(id); list.add(tname); list.add(cid); list.add(ttel); list.add(taddress); session.setAttribute("upTeachList", list); return "sys/upTeach"; } @ResponseBody @RequestMapping("/registerUser") public String registerUser(User user){ List id=userService.findAccount(user.getAccount()); if(id.size()!=0){ return "false"; } userService.registerUser(user); return "true"; } @RequestMapping("/addUser") public String addUser(){ return "sys/addUser"; } @RequestMapping("/addTeach") public String addTeach(){ return "sys/addTeach"; } @RequestMapping("/addApp") public String addApp(){ return "sys/addApp"; } @ResponseBody @RequestMapping("/upUserInfo") public String upUserInfo(Integer id,String account,Integer sex,Integer age,String name,String pwd,String tel,String address){ userService.updateUserInfo(id,account,sex,age,name,pwd,tel,address); return "true"; } @ResponseBody @RequestMapping(value="/upTeachInfo",method=RequestMethod.POST) public String upTeach(Integer id,String tname,Integer cid,String ttel,String taddress){ userService.upTeach(id,tname,cid,ttel,taddress); return "true"; } @ResponseBody @RequestMapping("/addTeachInfo") public String addTeachInfo(Teach teach){ userService.addTeachInfo(teach); return "true"; } @ResponseBody @RequestMapping("/addAppInfo") public String addAppInfo(String aname){ userService.addAppInfo(aname); return "true"; } }
拦截器配置:
public class SecurityServlet extends HttpServlet implements Filter{ private static final long serialVersionUID = 1L; public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { HttpServletRequest request=(HttpServletRequest)arg0; HttpServletResponse response =(HttpServletResponse) arg1; String count = (String) request.getSession().getAttribute("account"); String url=request.getRequestURI(); if(url.indexOf("login")<0){ if(count==null || "".equals(count) ) { response.sendRedirect(request.getContextPath()+"/login.jsp"); }else{ arg2.doFilter(arg0, arg1); } }else{ arg2.doFilter(arg0, arg1); } if(url.contains(".css") || url.contains(".js") || url.contains(".png")){ arg2.doFilter(arg0, arg1); } } public void init(FilterConfig arg0) throws ServletException { } }
到此这篇关于Java毕业设计实战之健身器材商城系统的实现的文章就介绍到这了,更多相关Java 商城系统内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!