I am in the process of getting to grips with the Spring MVC Framework. I have worked with the PHP Symfony Framework before and there are similar principles. However, I am struggling to create a model with my controller page that will handle a form submission. When a user signs into my system they are either a developer or a project manager. I have one class called a User class, and another class called Role - the latter determines whether the user has the role of Developer or Project Manager. I have the logic however, if you can advise me of how to handle form submission in my method.
I imported the User class. 1) This method displays a form "Get" method
@RequestMapping(value="/user-login", method=RequestMethod.GET)
public ModelAndView loginForm(){
return new ModelAndView("login-form");
}
2) This is the method that I am trying to use when retrieving the data "POST" method
@Autowired(value="/user-login", method=RequestMethod.POST)
public ModelAndView loginForm() {
if(user.getRole()=="User"){
System.out.println("This is the Developer View");
} else if(user.getRole()=="Admin"){
System.out.println("This is the Admin view");
}
}