В моем загрузочном проекте Spring передал объект DTO в мое представление, которое затем публикуется после отправки. например. Как получить доступ к «randomKey» после публикации формы?
@GetMapping("/{userId}/edit/feature/")
public String showEditFeature(@PathVariable("userId") Long userId, UserDto userDto,
Model model)
{
User user = userService.get(userId);
model.addAttribute("user", user);
model.addAttribute("randomKEy", "AnyObject");
return "user/edit/profile";
}
Тогда функция My post.
@PostMapping("profile_update")
public String watchFeatureUpdate(@Valid UserProfileDto UserProfileDto,
BindingResult result,
RedirectAttributes redirectAttributes, Model model)
{
Long userId = userService.updateUserProfile(userProfileDto);
redirectAttributes.addFlashAttribute("message", "Profile features updated
successfully!");
redirectAttributes.addFlashAttribute("alertClass", "alert-success");
return "redirect:/user/view/" + userId + "/profile";
}