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