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

struts2与spring mvc 的比较

时间:2014-11-29 10:25:19      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:sp   on   问题   bs   ad   new   tt   nbsp   type   

1、传值:

    struts2通过set get来传值,而spring mvc 可以直接在方法里传值(String username,Model model)model也可以换成map来传值但不建义

   model.addAttrubute("username",username),当然也可以直接写model.addAttribute(username),默认key是传值的值类string.

   model.addAttribute(new User()):key 就是User.

2、struts2 controller不支持单例,所以我们会在controller上加scope="prototype" 因为不加这句那就出问题了,对像的值公共了,而spring mvc刚支持单例,所以性能方便有所提高

struts2与spring mvc 的比较

标签:sp   on   问题   bs   ad   new   tt   nbsp   type   

原文地址:http://www.cnblogs.com/peter-peng/p/4130144.html

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