@RequestMapping(value = "/register", method = RequestMethod.POST) public String registerCustomer( @ModelAttribute(value = "customer") @Valid Customer customer, @RequestParam(value = "confirmPassword") String confirmPassword, RedirectAttributes redirectAttributes, Model model) { if (!confirmPassword.equals(customer.getUser().getPassword())) { model.addAttribute("registrationUnsuccessful", true); return "registerCustomer"; } try { if (customerService.createCustomer(customer)) { redirectAttributes.addAttribute("registrationSuccessful", true); return "redirect:/web/login"; } } catch (ConstraintViolationException ex) { model.addAttribute("wrongData", true); } model.addAttribute("registrationUnsuccessful", true); return "registerCustomer"; }