你好,我在春季将参数从一个映射传递到另一个映射时遇到问题。
@GetMapping("/board")
public String showBoard(@RequestParam("categoryId") int id, Model theModel) {
ForumCategory forumCategory = forumService.getForumCategory(id);
ForumPost forumPost = new ForumPost();
List<ForumPost> forumPosts = forumCategory.getForumPosts();
theModel.addAttribute("forumCategory", forumCategory);
theModel.addAttribute("forumPosts", forumPosts);
theModel.addAttribute(forumPost);
return "board";
}
@PostMapping("/saveForumPost")
public String saveForumPost(@ModelAttribute("forumPost") ForumPost forumPost, @ModelAttribute("forumCategory") ForumCategory forumCategory) {
forumService.saveForumPost(forumPost);
forumService.saveForumCategory(forumCategory);
return "redirect:/";
}
所以我要做的是保存forumPost并将其添加到具有/ board映射ID的论坛类别中。有没有办法将参数从/ board映射传递到/ saveForumPost映射?