示例#1
0
 @ModelAttribute("user")
 public User getUser() {
   User user = new User();
   user.setUserId("1001");
   user.setUserName("<>");
   return user;
 }
示例#2
0
 public void udateLoginInfo(User user) {
   String sqlStr =
       "update t_user set last_visit = ?,last_ip = ?,credits = ? " + " where user_id = ? ";
   jdbcTemplate.update(
       sqlStr,
       new Object[] {user.getLastVisit(), user.getLastIp(), user.getCreadits(), user.getUserId()});
 }
示例#3
0
 @RequestMapping(value = "/handle63")
 public String handle63(ModelMap modelMap) {
   User user = (User) modelMap.get("user");
   user.setUserName("tom");
   modelMap.addAttribute("testAttr", "value1");
   return "/user/showUser";
 }
示例#4
0
 @RequestMapping(value = "/handle72")
 public String handle72(ModelMap modelMap, SessionStatus sessionStatus) {
   User user = (User) modelMap.get("user");
   if (user != null) {
     user.setUserName("Jetty");
     sessionStatus.setComplete();
   }
   return "/user/showUser";
 }
示例#5
0
 @RequestMapping(value = "/handle92")
 public String handle92(@ModelAttribute("user") User user, BindingResult bindingResult) {
   ValidationUtils.rejectIfEmptyOrWhitespace(bindingResult, "userName", "required");
   if ("aaaa".equalsIgnoreCase(user.getUserName())) {
     bindingResult.rejectValue("userName", "reserved");
   }
   if (bindingResult.hasErrors()) {
     return "/user/register4";
   } else {
     return "/user/showUser";
   }
 }
示例#6
0
 @RequestMapping(value = "/showUserListMix")
 public String showUserListMix(ModelMap mm) {
   Calendar calendar = new GregorianCalendar();
   List<User> userList = new ArrayList<User>();
   User user1 = new User();
   user1.setUserName("tom");
   user1.setRealName("汤姆1");
   calendar.set(1980, 1, 1);
   user1.setBirthday(calendar.getTime());
   User user2 = new User();
   user2.setUserName("john");
   user2.setRealName("约翰");
   user2.setBirthday(calendar.getTime());
   userList.add(user1);
   userList.add(user2);
   mm.addAttribute("userList", userList);
   return "userListMix";
 }
示例#7
0
 @RequestMapping(value = "/handle71")
 public String handle71(@ModelAttribute("user") User user) {
   user.setUserName("John");
   return "redirect:handle72.html";
 }
示例#8
0
 @ModelAttribute("user2")
 public User getUser2() {
   User user = new User();
   user.setUserId("1");
   return user;
 }
示例#9
0
 @RequestMapping(value = "/handle62")
 public String handle62(@ModelAttribute("user") User user) {
   user.setUserName("tom");
   return "/user/showUser";
 }
示例#10
0
 @RequestMapping(value = "/handle61")
 public String handle61(@ModelAttribute("user") User user) {
   user.setUserId("1000");
   return "/user/createSuccess";
 }
示例#11
0
 @RequestMapping(value = "/handle51")
 public ResponseEntity<User> handle51(HttpEntity<User> requestEntity) {
   User user = requestEntity.getBody();
   user.setUserId("1000");
   return new ResponseEntity<User>(user, HttpStatus.OK);
 }