List of usage examples for org.springframework.beans BeanUtils copyProperties
private static void copyProperties(Object source, Object target, @Nullable Class<?> editable, @Nullable String... ignoreProperties) throws BeansException
From source file:com.kazuki43zoo.jpetstore.ui.controller.MyAccountController.java
@PostMapping("/update") public String update(@Validated AccountForm form, BindingResult result, @AuthenticationPrincipal(expression = "account") Account account, Model model, RedirectAttributes redirectAttributes) { if (result.hasErrors()) { model.addAttribute(new Messages().error("Input values are invalid. Please confirm error messages.")); return "account/updateForm"; }/* w w w . j av a2 s . c o m*/ BeanUtils.copyProperties(form, account, "username", "password"); accountService.updateAccount(account, form.getPassword()); publisher.publishEvent(new EntityChangedEvent<>(this, account)); redirectAttributes.addFlashAttribute(new Messages().success("Your account has been updated.")); return "redirect:/my/account/update?form"; }