标签:str forward ret response 绑定 mode 对象 direct null
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的页面,就会返回一个对象
springmvc 添加@ResponseBody
标签:str forward ret response 绑定 mode 对象 direct null
原文地址:http://www.cnblogs.com/harryGao65535/p/6958823.html