I'm working e-commerce store project using spring mvc. In a JSP login page, i need to check user name and user password after clicking submit button. If all information are ok then i'm gonna go to the next page, otherwise stay on the same page.
This is my Administrator class(Model) Administrator.java
@Entity
@Table(name="ADSMINISTRATOR")
public class Administrator {
@Id
private String userName;
private String userPassword;
//getter and setter
}
This is my controller class AdministratorController.java
@Controller
@RequestMapping(value="/administratorController")
public class AdministratorController {
@RequestMapping(value="/loginForm.html")
public ModelAndView getAdministratorLoginForm() {
return new ModelAndView("Administrator");
}
public ModelAndView goToMainPage(@ModelAttribute("administrator") Administrator administrator) {
//Checking userName and userPassword here
//if ok then
return new ModelAndView("mainPageDemo");
}
}
And this is my JSP(View) Administrator.jsp
<body>
<table>
<tr> <td>User Name: </td> <td><input type="text" name="userName" value="" placeholder="User Name"></input></td> </tr>
<tr> <td>User Password: </td> <td><input type="text" name="userPassword" value="" placeholder="User Password"></input></td> </tr>
<tr><td><input type="submit"></input></td> </tr>
</table>
</body>
</html>
Now When I click submit button in Administrator.jsp page, I need to execute goToMainPage() method in AdministratorController.java class. How can i do this?