简体   繁体   中英

User registration in java.

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?

@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:";


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM