为什么需要 ModelMap、Model、@ModelAttribute、ModelAndView 当字符串中 jsp 的简单 return 页面名称可以完成工作时
Why ModelMap, Model, @ModelAttribute, ModelAndView required when a simple return of jsp page name in string can do the work
我有以下 spring mvc 代码片段可以正常工作:
控制器片段:
@RequestMapping(value="/submitForm", method=RequestMethod.POST)
public String formSubmission(Employee employee)
{
return "EmployeeWelcome";
}
表格数据打印页面:
<html>
<h4>List of Request Parameters</h4>
<h4>first name - ${employee.firstName}</h4>
<h4>last name - ${employee.lastName}</h4>
<h4>user email - ${employee.email}</h4>
<h4>user salary - ${employee.salary}</h4>
</html>
上面打印成功了所有的值,那为什么还要下面的呢?
ModelMap, Model, @ModelAttribute, ModelAndView
如果您想从 java 端获取模型值或发送给 Ui 的任何消息,那么您需要这些
您可以在这里查看详细信息:What are the differences between Model, ModelMap, and ModelAndView?
我有以下 spring mvc 代码片段可以正常工作:
控制器片段:
@RequestMapping(value="/submitForm", method=RequestMethod.POST)
public String formSubmission(Employee employee)
{
return "EmployeeWelcome";
}
表格数据打印页面:
<html>
<h4>List of Request Parameters</h4>
<h4>first name - ${employee.firstName}</h4>
<h4>last name - ${employee.lastName}</h4>
<h4>user email - ${employee.email}</h4>
<h4>user salary - ${employee.salary}</h4>
</html>
上面打印成功了所有的值,那为什么还要下面的呢?
ModelMap, Model, @ModelAttribute, ModelAndView
如果您想从 java 端获取模型值或发送给 Ui 的任何消息,那么您需要这些
您可以在这里查看详细信息:What are the differences between Model, ModelMap, and ModelAndView?