/**
*ControllerA的代码
**/
@RequestMapping("addComment")
public String addComment(Comment comment,Model model){
if(cs.addComment(comment)){
model.addAttribute("id",comment.getCommentBookId());
//一定要加重定向
return "redirect:getBookDetail.action";
}
return "fail.jsp";
}
/**
*ControllerB的代码
**/
@RequestMapping("getBookDetail")
public String getBookDetail(Model model,@RequestParam(value="id",required=true)int id){
Book book = bs.getBookById(id);
model.addAttribute("book",book);
return "bookDetail.jsp";
}
网友评论