// 个人资料 @RequestMapping(value = "/buyer/profile.shtml") public String profile(HttpServletRequest request, ModelMap model) { // 加载用户 Buyer buyer = (Buyer) sessionProvider.getAttribute(request, Constants.BUYER_SESSION); Buyer b = buyerService.getBuyerByKey(buyer.getUsername()); model.addAttribute("buyer", b); // 省 List<Province> provinces = provinceService.getProvinceList(null); model.addAttribute("provinces", provinces); // 市 CityQuery cityQuery = new CityQuery(); cityQuery.setProvince(b.getProvince()); List<City> citys = cityService.getCityList(cityQuery); model.addAttribute("citys", citys); // 县 TownQuery townQuery = new TownQuery(); townQuery.setCity(b.getCity()); List<Town> towns = townService.getTownList(townQuery); model.addAttribute("towns", towns); return "buyer/profile"; }
/** * 1:验证码是否为null 2:验证码 是否正确 3:用户是否为NUll 4:密码是否为NUll 5:用户是否正确 6密码是否正确 Md5 纯生Md5 放进Session * 跳转ReturnUrl * * @param buyer * @param captcha * @param returnUrl * @return */ @RequestMapping(value = "/shopping/login.shtml", method = RequestMethod.POST) public String login( Buyer buyer, String captcha, String returnUrl, ModelMap model, HttpServletRequest request) { // 验证码是否为null if (StringUtils.isNotBlank(captcha)) { // 1:JSESSIONID // 2验证码 if (imageCaptchaService.validateResponseForID( sessionProvider.getSessionId(request), captcha)) { if (null != buyer && StringUtils.isNotBlank(buyer.getUsername())) { if (StringUtils.isNotBlank(buyer.getPassword())) { Buyer b = buyerService.getBuyerByKey(buyer.getUsername()); if (null != b) { // if (b.getPassword().equals(md5Pwd.encode(buyer.getPassword()))) { // 把用户对象放在Session sessionProvider.setAttribute(request, Constants.BUYER_SESSION, b); if (StringUtils.isNotBlank(returnUrl)) { return "redirect:" + returnUrl; } else { // 个人中心 return "redirect:/buyer/index.shtml"; } } else { model.addAttribute("error", "密码错误"); } } else { model.addAttribute("error", "用户名输入错误"); } } else { model.addAttribute("error", "请输入密码"); } } else { model.addAttribute("error", "请输入用户名"); } } else { model.addAttribute("error", "验证码输入错误"); } } else { model.addAttribute("error", "请填写验证码"); } return "buyer/login"; }