controller代码
@RequestMapping(method = RequestMethod.GET)
public String update(Model model) {
System.out.println("service update");
model.addAttribute("greetings", "I came from Model not ModelAttribute");
System.out.println(model.toString());
return "success";
}
成功后的html画面
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<body>
<h2>Add Book</h2>
bookname:<input type="text" name="name" id="name" value="${book.name}">
author:<input type="text" name="author" id="author" value="${book.author}">
<p><c:out value="${greetings}" /> </p>
<p>${greetings}</p>
</body>
</html>
最后页面上始终是${greetings}