[英]How to pass LIST from one controller to another controller in spring mvc
[英]How to get variables from one Spring MVC Controller to Another
我是春天的新手。 你能幫我設計一下嗎?
我新編寫的Controller A與模型屬性“attribA”綁定,而新的jsp是customerInformation。
現在我已經存在與模型屬性“attribB”綁定的Controller B,而jsp是現有的customerSummary,我將根據需要修改我想要顯示用戶在模型attribA中的前一個jsp上設置的內容。
如何從現有控制器控制器B中的新控制器A傳遞內容或attributeA以在第二個jsp customerSummary上顯示
謝謝
你可以使用“RedirectAttributes”來做到這一點
@PostMapping("/userWiseNewMenuPermission")
public ModelAndView setUserWiseNewMenuPermission(ModelAndView modelAndView,RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("comfmMassg","Menu Permission Save Successful!");
modelAndView.setViewName("redirect:/userList?page=1");
return modelAndView;
}
在此Post控制器中重定向到具有屬性名稱“comfmMassg”的get控制器......
@GetMapping("/userList")
public ModelAndView getMenu(ModelAndView modelAndView,@ModelAttribute("comfmMassg") String masg) {
modelAndView.addObject("masg", masg);
modelAndView.setViewName("userList");
return modelAndView;
}
這個例子在春季啟動工作............
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.