「Spring」BeanUtils.copyPropertiesを利用するサンプル

サンプルコード

	 @RequestMapping(value = "update", method = RequestMethod.POST)
         String update(@Validated UserForm form, BindingResult result, Model model) {
           if (result.hasErrors()) {
             return xxx;
          }
          User user = new User();
          BeanUtils.copyProperties(form, user);
          //some code
          return xxx;
        }

 

Software

Posted by arkgame