ModelAndView

SpringMVC 会把 ModelAndView 的 model 中数据放入到 request 域对象中。

Controller 中添加

	@RequestMapping("/modelAndView")
	public ModelAndView testModelAndView() {
		String viewName = "success";
		ModelAndView modelAndView = new ModelAndView(viewName );
		Date date = new Date() ;
		modelAndView.addObject("time" , date) ;
		return modelAndView  ; 
	}

success.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h4>success</h4>
	time: ${ requestScope.time }
</body>
</html>

Map

https://www.bilibili.com/video/av49996848?p=15





操作:


@SessionAttributes