码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 4 官方文档学习(十一)Web MVC 框架之约定优于配置

时间:2016-12-11 17:51:43      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:lis   empty   ant   hashset   instance   ati   res   nts   element   

当返回一个ModelAndView时,可以使用其addObject(Object obj)方法,此时的约定是:

  • An x.y.User instance added will have the name user generated.
  • An x.y.Registration instance added will have the name registration generated.
  • An x.y.Foo instance added will have the name foo generated.
  • A java.util.HashMap instance added will have the name hashMap generated. You probably want to be explicit about the name in this case because hashMap is less than intuitive.
  • Adding null will result in an IllegalArgumentException being thrown. If the object (or objects) that you are adding could be null, then you will also want to be explicit about the name.

还有:

  • An x.y.User[] array with zero or more x.y.User elements added will have the name userList generated.
  • An x.y.Foo[] array with zero or more x.y.User elements added will have the name fooList generated.
  • A java.util.ArrayList with one or more x.y.User elements added will have the name userList generated.
  • A java.util.HashSet with one or more x.y.Foo elements added will have the name fooList generated.
  • An empty java.util.ArrayList will not be added at all (in effect, the addObject(..) call will essentially be a no-op).

 

官方文档链接:

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-coc

Spring 4 官方文档学习(十一)Web MVC 框架之约定优于配置

标签:lis   empty   ant   hashset   instance   ati   res   nts   element   

原文地址:http://www.cnblogs.com/larryzeal/p/6160030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!