scope="prototype" 设置ssh中action为多例

scope="prototype" 设置ssh中action为多例,如   

<bean name="accountActionBean" scope="prototype" class="xxx.action.AccountAction">

    <property name="accountService" ref="accountServiceImpl" />

  </bean>

......

这样的话保证每次都new一个新的action,避免单个action中的属性值连续传递,例如,原来user.addTime="2017-01-11 12:23:13"

如果是单列的action的话,如果jsp中没有设置user.addTime,页面提交后,action会使用上次保存的属性值,也就是"2017-01-11 12:23:13",并不是null值。多例的话就不会出现这种情况,而是user.addTime=null。所以一般要设置scope="prototype" 

猜你喜欢

转载自yzl495.iteye.com/blog/2387666
今日推荐