»·¾³ÅäÖãº
Jdk1.8 + Tomcat8.5 + mysql + Eclispe£¨IntelliJ IDEA,Eclispe,MyEclispe,Sts¶¼Ö§³Ö£©
ÏîÄ¿¼¼Êõ£º
JSP +Spring + SpringMVC + MyBatis + css + JavaScript + JQuery + Ajax + layui+ mavenµÈµÈ¡£
/** * ¹ÜÀíÔ±controller */ @Controller @RequestMapping("/config") public class UserController { @Autowired UserRoleService userRoleService; @Autowired UserService userService; @Autowired RoleService roleService; @RequestMapping("/enableStatus") @ResponseBody public String enableStatus(@RequestParam(value = "name") String name){ return userService.enableStatus(name); } @RequestMapping("/stopStatus") @ResponseBody public String stopStatus(@RequestParam(value = "name") String name){ return userService.stopStatus(name); } @RequestMapping("/adminAdd") public String adminadd(Model model){ List<Role> list = roleService.list(); model.addAttribute("rolelist",list); return "syspage/admin-add"; } @RequestMapping("/listUser") public String list(Model model, Page page){ PageHelper.offsetPage(page.getStart(),page.getCount());//·ÖÒ³²éѯ List<User> us= userService.list(); int total = (int) new PageInfo<>(us).getTotal();//×ÜÌõÊý page.setTotal(total); model.addAttribute("us", us);//ËùÓÐÓû§ model.addAttribute("total",total); Map<User,List<Role>> user_roles = new HashMap<>(); //ÿ¸öÓû§¶ÔÓ¦µÄȨÏÞ for (User user : us) { List<Role> roles=roleService.listRoles(user); user_roles.put(user, roles); } model.addAttribute("user_roles", user_roles); return "syspage/admin-list"; } /** * Ð޸ĹÜÀíÔ±½ÇÉ« * @param model * @param id * @return */ @RequestMapping("/editUser") public String edit(Model model,Long id){ List<Role> rs = roleService.list(); model.addAttribute("rs", rs); User user =userService.get(id); model.addAttribute("user", user); //µ±Ç°ÓµÓеĽÇÉ« List<Role> roles =roleService.listRoles(user); model.addAttribute("currentRoles", roles); return "syspage/admin-edit"; } @RequestMapping("deleteUser") public String delete(Model model,long id){ userService.delete(id); return "redirect:listUser"; } @RequestMapping("updateUser") public String update(User user, long[] roleIds){ userRoleService.setRoles(user,roleIds); String password=user.getPassword(); //Èç¹ûÔÚÐ޸ĵÄʱºòûÓÐÉèÖÃÃÜÂ룬¾Í±íʾ²»¸Ä¶¯ÃÜÂë if(user.getPassword().length()!=0) { String salt = new SecureRandomNumberGenerator().nextBytes().toString(); int times = 2; String algorithmName = "md5"; String encodedPassword = new SimpleHash(algorithmName,password,salt,times).toString(); user.setSalt(salt); user.setPassword(encodedPassword); } else user.setPassword(null); userService.update(user); return "redirect:listUser"; } @RequestMapping("addUser") public String add(User user,long[] roleIds){ String salt = new SecureRandomNumberGenerator().nextBytes().toString();//Éú³ÉËæ»úÊý int times = 2; String algorithmName = "md5"; String encodedPassword = new SimpleHash(algorithmName,user.getPassword(),salt,times).toString(); User u = new User(); u.setName(user.getName()); u.setPassword(encodedPassword); u.setSalt(salt); u.setStatus(1); u.setAddress(user.getAddress()); u.setPhone(user.getPhone()); userService.add(u); userRoleService.setRoles(u,roleIds); return "redirect:listUser"; } }
/** * ¹ÜÀíÔ±½ÇÉ«controler */ @Controller @RequestMapping("/config") public class RoleController { @Autowired RoleService roleService; @Autowired RolePermissionService rolePermissionService; @Autowired PermissionService permissionService; @RequestMapping("/addRoleUI") public String addRole(){ return "syspage/admin-role-add"; } @RequestMapping("/listRole") public String list(Model model, Page page){ PageHelper.offsetPage(page.getStart(),page.getCount());//·ÖÒ³²éѯ List<Role> rs= roleService.list(); int total = (int) new PageInfo<>(rs).getTotal();//×ÜÌõÊý page.setTotal(total); model.addAttribute("rs", rs); model.addAttribute("roleSize",total); Map<Role,List<Permission>> role_permissions = new HashMap<>(); for (Role role : rs) { List<Permission> ps = permissionService.list(role); role_permissions.put(role, ps); } model.addAttribute("role_permissions", role_permissions); return "syspage/admin-role"; } @RequestMapping("/editRole") public String list(Model model,long id){ Role role =roleService.get(id); model.addAttribute("role", role); //ËùÓÐȨÏÞ List<Permission> ps = permissionService.list(); model.addAttribute("ps", ps); //µ±Ç°¹ÜÀíÔ±ÓµÓеÄȨÏÞ List<Permission> currentPermissions = permissionService.list(role); model.addAttribute("currentPermissions", currentPermissions); return "syspage/admin-role-edit"; } @RequestMapping("/updateRole") public String update(Role role,long[] permissionIds){ rolePermissionService.setPermissions(role, permissionIds); roleService.update(role); return "redirect:listRole"; } @RequestMapping("/addRole") public String list(Model model,Role role){ roleService.add(role); return "redirect:listRole"; } @RequestMapping("/deleteRole") public String delete(Model model,long id){ roleService.delete(id); return "redirect:listRole"; } }
/** * ºǫ́µÇ½ */ @Controller @RequestMapping("") public class LoginController { @Autowired UserService userService; @RequestMapping(value="/login",method=RequestMethod.POST) public String login(Model model, String name, String password){//throws ParseException Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(name,password); try { subject.login(token); User us = userService.getByName(name); String lastLoginTime = ""; if(us!=null){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //ÉÏ´Îʱ¼ä Date time = us.getLasttime(); lastLoginTime = sdf.format(time); //ÐÂʱ¼ä String format = sdf.format(new Date()); //stringתdate ²»´¦Àíʱ¼ä¸ñʽ»á²»ÀíÏë ParsePosition pos = new ParsePosition(0); Date strtodate = sdf.parse(format, pos); us.setLasttime(strtodate); userService.update(us); } if (us.getStatus()==1){ Session session=subject.getSession(); session.setAttribute("subject", subject); session.setAttribute("lastLoginTime",lastLoginTime); return "redirect:index"; }else { model.addAttribute("error", "Õ˺ÅÒѱ»Í£Óã¡"); return "/login"; } } catch (AuthenticationException e) { model.addAttribute("error", "Ñé֤ʧ°Ü£¡"); return "/login"; } } }
/** * ¶©µ¥Ä£¿écontroller */ @Controller @RequestMapping("/order") public class OrderController { @Autowired OrderService orderService; @Autowired OrderItemService orderItemService; /** * ËùÓж©µ¥ * @param model * @param page * @return */ @RequestMapping("/list") public String list(Model model, Page page){ PageHelper.offsetPage(page.getStart(),page.getCount()); List<Order> os= orderService.list(); int total = (int) new PageInfo<>(os).getTotal(); page.setTotal(total); //Ϊ¶©µ¥Ìí¼Ó¶©µ¥ÏîÊý¾Ý orderItemService.fill(os); model.addAttribute("os", os); model.addAttribute("page", page); model.addAttribute("totals", total); return "ordermodule/order-list"; } /** * ¶©µ¥·¢»õ * @param o * @return */ @RequestMapping("/orderDelivery") public String delivery(Order o){ o.setStatus(2); orderService.update(o); return "redirect:list"; } /** * ²é¿´µ±Ç°¶©µ¥µÄ¶©µ¥Ïî * @param oid * @param model * @return */ @RequestMapping("/seeOrderItem") public String seeOrderItem(int oid,Model model){ Order o = orderService.get(oid); orderItemService.fill(o); model.addAttribute("orderItems",o.getOrderItems()); model.addAttribute("total",o.getOrderItems().size()); model.addAttribute("totalPrice",o.getTotal()); return "ordermodule/orderItem-list"; } }
ÒÔÉϾÍÊÇJavaʵս֮У԰ÍâÂôµã²ÍϵͳµÄʵÏÖµÄÏêϸÄÚÈÝ£¬¸ü¶à¹ØÓÚJavaµã²ÍϵͳµÄ×ÊÁÏÇë¹Ø×¢Ô´ÂëËѲØÍøÆäËüÏà¹ØÎÄÕ£¡
Apache Solr ³õ¼¶½Ì³Ì£¨½éÉÜ¡¢°²×°²¿Êð¡¢Ja
Javaö¾ÙÓëÆÕͨÀàµÄÇø±ðºÍʹÓÃÈ«½âÎö
Java(5/6ºÍ8)ÖÐinterfaceºÍAbstract Class
Ãâ·ÑjavaÊÓƵÏÂÔØ£¬strutsÊÓƵ£¬hibernate
EclipseÖÐÅäÖÃAjaxµÄDWRµÄ¼òµ¥·½·¨
¶¯Á¦½Úµã_ÍõÓÂ_ DRPÏîÄ¿ÊÓƵ½Ì³ÌÍêÕû°æ292
OracleÃÜıB¼Æ»® JDK 7»ò³ÉÌøƱÍõ
ÈÈÃÅÔ´Âë