Guest User

Untitled

a guest
Feb 1st, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package net.codejava.spring.model;
  2.  
  3. import java.util.Date;
  4.  
  5. public class User {
  6.  
  7. private String username;
  8. private String password;
  9. private String email;
  10. private Date birthDate;
  11. private String profession;
  12.  
  13. public String getUsername() {
  14. return username;
  15. }
  16.  
  17. public void setUsername(String username) {
  18. this.username = username;
  19. }
  20.  
  21. public String getPassword() {
  22. return password;
  23. }
  24.  
  25. public void setPassword(String password) {
  26. this.password = password;
  27. }
  28.  
  29. public String getEmail() {
  30. return email;
  31. }
  32.  
  33. public void setEmail(String email) {
  34. this.email = email;
  35. }
  36.  
  37. public Date getBirthDate() {
  38. return birthDate;
  39. }
  40.  
  41. public void setBirthDate(Date birthDate) {
  42. this.birthDate = birthDate;
  43. }
  44.  
  45. public String getProfession() {
  46. return profession;
  47. }
  48.  
  49. public void setProfession(String profession) {
  50. this.profession = profession;
  51. }
  52.  
  53. }
  54. //////////////////////////////////
  55. package net.codejava.spring.controller;
  56.  
  57. import java.util.ArrayList;
  58. import java.util.List;
  59. import java.util.Map;
  60.  
  61. import org.springframework.stereotype.Controller;
  62. import org.springframework.web.bind.annotation.ModelAttribute;
  63. import org.springframework.web.bind.annotation.RequestMapping;
  64. import org.springframework.web.bind.annotation.RequestMethod;
  65.  
  66. import net.codejava.spring.model.User;
  67.  
  68. @Controller
  69. @RequestMapping(value = "/register")
  70.  
  71. public class RegisterController {
  72. @RequestMapping(method = RequestMethod.GET)
  73. public String viewRegistration(Map<String, Object> model) {
  74. User userForm = new User();
  75. model.put("userForm", userForm);
  76. List<String> professionList = new ArrayList();
  77. professionList.add("Developer");
  78. professionList.add("Designer");
  79. professionList.add("IT Manager");
  80. model.put("professionalList", professionList);
  81. return "Registration";
  82.  
  83. }
  84.  
  85. @RequestMapping(method = RequestMethod.POST)
  86. public String processRegistration(@ModelAttribute("userForm") User user, Map<String, Object> model) {
  87. System.out.println("usename :" + user.getUsername());
  88. System.out.println("password :" + user.getPassword());
  89. System.out.println("email :" + user.getEmail());
  90. System.out.println("birth date :" + user.getBirthDate());
  91. System.out.println("profession: " + user.getProfession());
  92. return "RegistrationSuccess";
  93. }
  94.  
  95. }
Add Comment
Please, Sign In to add comment