model.addattribute()的作用

1.往前台传数据,可以传对象,可以传List,通过el表达式 ${}可以获取到,

类似于request.setAttribute("sts",sts)效果一样。

[email protected]("model")   注解

参考:https://blog.csdn.net/qq_21050291/article/details/72724607

原文地址:https://www.cnblogs.com/yingyigongzi/p/9295696.html

时间: 2024-08-01 03:58:38

model.addattribute()的作用的相关文章

model.addAttribute("method", "update");

@RequestMapping(method = RequestMethod.GET, value = "/update/{id}")public String forUpdate(Model model, @PathVariable("id") Long id) { SystemRole systemRole = systemRoleService.getById(id); model.addAttribute("systemRole", sy

SpringMVC中 -- @RequestMapping的作用及用法

一.@RequestMapping 简介 在Spring MVC 中使用 @RequestMapping 来映射请求,也就是通过它来指定控制器可以处理哪些URL请求,相当于Servlet中在web.xml中配置 <servlet> <servlet-name>servletName</servlet-name> <servlet-class>ServletClass</servlet-class> </servlet> <ser

Spring MVC:Model、View、ModelAndView

个人理解:View为服务器上的某个文件容器,可以为JSP,FTL等动态页面文件,甚至是媒体文件等等,单单是一个文件.Model的作用是存储动态页面属性,动态页面文件即View可以在Model中获取动态数据,这样就实现了View和Model分离的目的.接下来分别对这三个做一下说明. 一.首先是View:View接口在org.springframework.web.servlet.View包内.核心方法: 1.getContentType()获取当前view的ContentType(),同http请

@ModelAttribute注解的作用

@ModelAttribute注解的作用:1.放在方法上注解不带属性: 方法无返回值: 执行其他方法时,先执行该注解标记方法. 如果方法中有将一些属性放入model的操作,其他方法model中也会共享注解标注方法的model属性. 方法返回对象: 执行其他方法时,先执行该注解标注的方法. 如果有将属性放入model的操作,model中的数据也会共享 方法的返回值会自动装入model中,key值如果没有指定的话为返回对象类型的首字母小写.指定key的话给注解的value属性赋值即可.方法返回的值可

ModelMap和ModelAndView的作用

首先介绍ModelMap和ModelAndView的作用 ModelMap ModelMap对象主要用于传递控制方法处理数据到结果页面,也就是说我们把结果页面上需要的数据放到ModelMap对象中即可,他的作用类似于request对象的setAttribute方法的作用,用来在一个请求过程中传递处理的数据.通过以下方法向页面传递参数: addAttribute(String key,Object value); 在页面上可以通过el变量方式$key或者bboss的一系列数据展示标签获取并展示mo

spring框架中ModelAndView、Model、ModelMap区别

转载来源:http://www.cnblogs.com/google4y/p/3421017.html 注意:如果方法声明了注解@ResponseBody ,则会直接将返回值输出到页面. 首先介绍ModelMap[Model]和ModelAndView的作用 Model 是一个接口, 其实现类为ExtendedModelMap,继承了ModelMap类. ModelMapModelMap对象主要用于传递控制方法处理数据到结果页面,也就是说我们把结果页面上需要的数据放到ModelMap对象中即可,

SpringMVC(二)--处理数据模型、ModelAndView、Model、Map、重定向、@ModelAttribute、

1.处理模型数据 Spring MVC 提供了以下几种途径输出模型数据: – ModelAndView:处理方法返回值类型为 ModelAndView 时, 方法体即可通过该对象添加模型数据 – Map 及 Model.ModelMap: 入参为 org.springframework.ui.Model.org.springframework.ui. ModelMap 或 java.uti.Map 时,处理方法返回时,Map 中的数据会自动添加到模型中. 无论返回值是String类型,还是Mod

(六)springmvc之ModelAndView、Model、Map、ModelMap

<a href="<%=request.getContextPath()%>/responseData/response_1">使用原生的作用域</a> <a href="<%=request.getContextPath()%>/responseData/response_2">ModelAndView</a> <a href="<%=request.getContext

Spring Boot&mdash;10ModelAndView、Model,以及@ModelAttribute注解

package com.sample.smartmap.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; i