通過ModelAndView實現(xiàn)頁面跳轉(zhuǎn),可以按照以下步驟進行:
@RequestMapping("/example")
public ModelAndView example() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("examplePage");
return modelAndView;
}
@RequestMapping("/example")
public ModelAndView example() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("examplePage");
modelAndView.addObject("data", "Hello, World!");
return modelAndView;
}
<!DOCTYPE html>
<html>
<head>
<title>Example Page</title>
</head>
<body>
<h1>${data}</h1>
</body>
</html>
通過以上步驟,就可以通過ModelAndView實現(xiàn)頁面跳轉(zhuǎn),并且在跳轉(zhuǎn)的頁面中使用數(shù)據(jù)模型。