@RequestMapping(value = "/edit", method = RequestMethod.GET) public String changePwdForm( HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) { Object user = request.getSession().getAttribute("user"); if (user == null) { redirectAttributes.addFlashAttribute("info", "非法请求"); return "redirect:" + LOGIN_INPUT; } model.addAttribute("user", user); User u = (User) user; List<Social> socials = socialService.listByUserId(u.getId()); socials.forEach( social -> { Arrays.asList(Social.TYPES) .forEach( t -> { if (social.getType().equals(t)) { model.addAttribute(t, social); } }); }); return "user/edit"; }