title: User registration in java.
body: <p>I am trying to create a user registration in java.  I have already created a Musician class.  I am looking to improve the controller. The password currently doesn't work properly and how can I create a user that has a unique identifier?</p>
  
  <pre><code>@Controller
  @RequestMapping("musician")
  public class MusicianController {
  
  @RequestMapping (value = "")
  public String index (Model model) {
  
      model.addAttribute("title", "Musician Connect");
      return "musician/index";
  
  }
  
  @RequestMapping (value = "add", method = RequestMethod.GET)
  public String add(Model model) {
      model.addAttribute(new Musician());
      model.addAttribute("title", "Create an Account");
      return "musician/add";
  }
  
  @RequestMapping(value = "add", method = RequestMethod.POST)
  public String add(@ModelAttribute @Valid Musician musician,
                    Errors errors,
                    String verify,
                    Model model) {
  
      model.addAttribute("musician", musician);
      boolean passwordsMatch = true;
  
      if (errors.hasErrors()) {
          return "musician/add";
  
      }
      if (musician.getPassword() == null || verify == null
              || !musician.getPassword().equals(verify)) {
          passwordsMatch = false;
      }
      if (passwordsMatch) {
          return "redirect:/login";
      }
  
      return "redirect:";
  
  
  }
  </code></pre>