Skip to content

Instantly share code, notes, and snippets.

@rankun203
Last active December 26, 2015 20:19
Show Gist options
  • Save rankun203/7207805 to your computer and use it in GitHub Desktop.
Save rankun203/7207805 to your computer and use it in GitHub Desktop.
SpringMVC 指定返回页面的两种方式
@RequestMapping("/")
public ModelAndView welcome (ModelMap model) {
ModelAndView view = new ModelAndView("index");
model.addAttribute("introSelf", "I'm Spring, I'm Coming.");
return view;
}
@RequestMapping("/")
public String welcome (ModelMap model) {
model.addAttribute("introSelf", "I'm Spring, I'm Coming.");
return "index";
}
//ModelMap 对象可以用来存储回传变量
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment