1.添加ResponseBody之后的话 返回字符串的时候 就是一个字符串、
@RequestMapping(value = "/{bookId}/detail.do",method = RequestMethod.GET)
@ResponseBody
private String detail(@PathVariable("bookId")Long bookId ,Model model){
if(bookId == null){
return "redirect:/book/list";
}
Book book = bookService.getById(bookId);
if(book == null){
return "forward:/book/list";
}
model.addAttribute("detail",book);
return "detail";
}
2. 如果不添加ResponseBody的话 model对象才能绑定到jsp的页面,就会返回一个对象