0
我甲肝家庭控制器內我甲肝2層的方法之一是如何使用屬性值從一個方法到另一方法
@RequestMapping(value = "/mypage.te", method = RequestMethod.GET)
public String mypage1(Locale locale, Model model){
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName(); //get logged in username
model.addAttribute("username", name);
model.addAttribute("customGroup",grpDao.fetchCustomGroup());
model.addAttribute("serverTime", formattedDate);
model.addAttribute("username", name);
return "mypage";
}
這裏在該方法實際上我把來自其執行一個道類grpDao.fetchCustomGroup()
方法原生查詢並提取數據並返回,並保存在customGroup
中。
現在同樣fetchcustomGroup()
方法是另一種方法來使用,即
@RequestMapping(value = "/manageGrps.te", method = RequestMethod.GET)
public String man_grp_connections(@RequestParam("id") Integer groupId,@RequestParam("name") String groupName, Model model) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String name = auth.getName();
System.out.println("I am in the fetchCustomGroup controller");
int profileid=grpDao.getProfileId(name);
//model.addAttribute("customGroup",grpDao.fetchCustomGroup());
model.addAttribute("memberList",grpDao.fetchGroupMembers(groupId,profileid));
model.addAttribute("groupid",groupId);
model.addAttribute("profileid",profileid);
model.addAttribute("groupName",groupName);
System.out.println("groupid="+groupId);
System.out.println("groupName="+groupName);
return "manageGrps";
}
所以不是在這兩個我只是想在只有一個方法調用和使用結果的方法調用fetchCustomGroup()
的兩個家庭控制器中的方法。
憑什麼我用customGroup在另一種方法使用的fetchCustomGroup()
我只想複製第一個方法從數據庫中檢索到的相同數據 – amit
我不想再次調用同一個方法 – amit