Spring MVC中注解 @ModelAttribute
1、@ModelAttribute放在方法之上,在当前Control内的所有方法映射多个URL的请求,都会执行该方法
@ModelAttribute
public void itemsCommon(HttpServletRequest request,Model model){
model.addAttribute("common", "common111");
}
2、如果在请求链接中没有参数abc,塞入到model中的参数值为null
@ModelAttribute
public void itemsCommon(HttpServletRequest request,Model model,String abc){
model.addAttribute("common", abc);
}
3、和上述方法的 model.addAttribute("common", abc);效果相同
@ModelAttribute(value="common")
public String itemsCommon(HttpServletRequest request,Model model,String abc){
return abc;
}
4、如果不设置value值,则attribute的key值隐式设置为类型(首字母小写),如下理解为 model.addAttribute("string", abc)
如果返回类型为model,则为model类名的小写,如model.addAttribute("persion", abc)
@ModelAttribute
public String itemsCommon(HttpServletRequest request,Model model,String abc){
return abc;
}
5、@ModelAttribute和@RequestMapping可以同时放在一个方法上
6、@ModelAttribute可以放在参数前面
@RequestMapping("/testCommon")
public String itemsCommon(@ModelAttribute String abc){
return abc;
}
Spring MVC中注解 @ModelAttribute的更多相关文章
- Spring MVC中注解: @ModelAttribute 与@RequestParam区别
相关链接 : https://blog.csdn.net/huang343/article/details/77491096
- Spring MVC中注解的简介
参考网址: https://blog.csdn.net/a67474506/article/details/46361195 @RequestMapping映射请求 SpringMVC 使用 @Re ...
- Spring MVC 中 @ModelAttribute 注解的妙用
Spring MVC 中 @ModelAttribute 注解的妙用 Spring MVC 提供的这种基于注释的编程模型,极大的简化了 web 应用的开发.其中 @Controller 和 @Rest ...
- Spring MVC 中的基于注解的 Controller【转】
原文地址:http://my.oschina.net/abian/blog/128028 终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 H ...
- Spring MVC中基于注解的 Controller
终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 HandlerMapping 来映射出相应的 handler 并调用相应的方法以响 ...
- Spring MVC 中的基于注解的 Controller(转载)
终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 HandlerMapping 来映射出相应的 handler 并调用相应的方法 ...
- Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法
Spring MVC 中采用注解方式 Action中跳转到另一个Action的写法 在Action中方法的返回值都是字符串行,一般情况是返回某个JSP,如: return "xx" ...
- Spring 注解驱动(二)Servlet 3.0 注解驱动在 Spring MVC 中的应用
Spring 注解驱动(二)Servlet 3.0 注解驱动在 Spring MVC 中的应用 Spring 系列目录(https://www.cnblogs.com/binarylei/p/1019 ...
- spring 以及 spring mvc 中常用注解整理
spring 以及 spring mvc 中常用注解整理 @RequestMapping(映射路径) @Autowired(注入 bean 对象) 例如: @Autowired private Bas ...
随机推荐
- rt: Unknown command 'PATH='
- 【转】Android编译系统详解(三)——编译流程详解
原文网址:http://www.cloudchou.com/android/post-276.html 本文原创作者:Cloud Chou. 欢迎转载,请注明出处和本文链接 1.概述 编译Androi ...
- Render To Texel Baker
今天仔细研究了 Shaowgun 示例中那个金黄色雕像所使用的光照纹理烘焙工具:“Render To Texel Baker”.因为要在移动设备展现比较逼真的光照效果,但是实时使用法线贴图并大量用于场 ...
- 自主架设VOIP系统
my.oschina.net/fcboys/blog/2695 FXS (Foreign Exchange Station) FXS is an interface which drives a te ...
- 爬虫技术浅析 | z7y Blog
爬虫技术浅析 | z7y Blog 爬虫技术浅析
- winform DataGridView双击修改单元格的值 分类: DataGridView 2014-08-04 19:39 150人阅读 评论(0) 收藏
定义全局变量 string abcmycode = "";//当前行自编号 bool tf = false;//是否双击 //双击可编辑 private void ...
- 编译LOADCEPC.EXE程序
1.安装编译工具 安装MSVC152路径C:/MSVC; 安装MASM611可以自己指定E:/MASM611; 命令行编译 相关文件配置 修改setupen2.bat 如下: :PATH_DONE s ...
- OfficePickers
OfficePickers http://www.codeproject.com/Articles/12327/Office-2003-Color-Picker 来自为知笔记(Wiz) 附件列 ...
- Delphi TWebBrowser
Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...
- mysql 源码编绎修改 FLAGS,调试MYSQL
http://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html#option_cmake_cmake_c_flags ...