Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. @DynamicUpdate
  2. public class EntityUser
  3. {
  4. String login;
  5. String password;
  6.  
  7. public EntityUser() {}
  8.  
  9. public EntityUser
  10. (
  11. String login,
  12. String password
  13. )
  14. {
  15. this.login = login;
  16. this.password = password;
  17. }
  18.  
  19. public String getLogin() {
  20. return login;
  21. }
  22.  
  23. public void setLogin(String login) {
  24. this.login = login;
  25. }
  26.  
  27. public String getPassword() {
  28. return password;
  29. }
  30.  
  31. public void setPassword(String password) {
  32. this.password = password;
  33. }
  34. }
  35.  
  36. <form action="#" th:action="@{/loginCheck}" th:object="${user}" method="post">
  37. <table border="1" width="30%" cellpadding="3">
  38. <thead>
  39. <tr>
  40. <th colspan="2">Login Here</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. <tr>
  45. <td>User Name</td>
  46. <td><input type="text" th:field="*{login}"/></td>
  47. </tr>
  48. <tr>
  49. <td>Password</td>
  50. <td><input type="password" th:field="*{password}"/></td>
  51. </tr>
  52. <tr>
  53. <td><input type="submit" value="Login" /></td>
  54. <td><input type="reset" value="Reset" /></td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </form>
  59.  
  60. @RequestMapping(value = "/loginCheck", method = RequestMethod.GET)
  61. public String userForm(Model model)
  62. {
  63. EntityUser user = new EntityUser();
  64. user.setLogin("login");
  65. user.setPassword("password");
  66. model.addAttribute("user", user);
  67.  
  68. System.out.println(user.getLogin());
  69. System.out.println(user.getPassword());
  70.  
  71. return "/loginCheck";
  72. }
  73.  
  74. @RequestMapping(value = "/loginCheck", method = RequestMethod.POST)
  75. public String processUser(@ModelAttribute(value="user") EntityUser user)
  76. {
  77.  
  78. System.out.println(user.getLogin());
  79. System.out.println(user.getPassword());
  80.  
  81. loginInfo = "Jakarta";
  82. return "redirect:/controllers";
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement