代码如下:
@RequestMapping({"/","/index"})
public String index(Model model) {
//1.获取所有的首页栏目
List<Channel> cs = channelService.listTopNavChannel();
model.addAttribute("cs",cs);
BaseInfo bi = BaseInfoUtil.getInstacne().read();
int picNum = bi.getIndexPicNumber();
model.addAttribute("shxw", topicService.listTopicByChannelAndNumber(10,14));
model.addAttribute("ggl", topicService.listTopicByChannelAndNumber(13,8));
model.addAttribute("xxkd", topicService.listTopicByChannelAndNumber(22,8));
model.addAttribute("pics",indexPicService.listIndexPicByNum(picNum));
model.addAttribute("shdt", listByParentNavAttachment(2));
model.addAttribute("shhd",attachmentService.listChannelPic(11,4));
model.addAttribute("shkh", attachmentService.listChannelPic(23,1));
model.addAttribute("shky", listByParentNavAttachment(3));//图片
model.addAttribute("yqlj", cmsLinkService.findByType(null).getDatas());
model.addAttribute("baseInfo", BaseInfoUtil.getInstacne().read());
return "index/index";
}
@RequestMapping("/topic/{tid}")
public String showTopic(@PathVariable int tid,Model model) {
model.addAttribute("topic", topicService.load(tid));
List<Attachment> atts = attachmentService.listAttachByTopic(tid);
if(atts.size()>0) {
model.addAttribute("hasAtts", true);
model.addAttribute("atts", atts);
} else {
model.addAttribute("hasAtts",false);
}
return "index/topic";
}
如果我再index页面已经获取cs等index方法已经给model赋的值.那么当我从
index页面点击链接跳转到topic页面时,我如何获取原先在index方法已经赋值的值?
有几种办法?有没有优缺点