本章节主要讲解使用springmvc进行controller到view的转向,涉及代码包含JSP视图,
和上一章节最大的配置点不同是:
无任何视图指向的Controller @ResponseBody是关键代码
@Controller public class MappingController { @RequestMapping("/mapping/path") public @ResponseBody String byPath() { return "Mapped by path!"; } }
指向具体视图的Controller,@ResponseBody
@Controller @RequestMapping("/views/*") public class ViewsController { @RequestMapping(value="html", method=RequestMethod.GET) public String prepare(Model model) { model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; }
先打个标记,明天继续》。。。。。