解决ssh中使用struts2验证框架提示错误后正确无法提交的问题

struts和spring整合,因为action由spring进行管理,需要在spring配置文件中设置相对应的action的属性scope="prototype",绝对不能用默认值scope="singleton",设置成scope="prototype"相当于每次都会去new一个实例,否则用一个实例去去处理所有的请求,就会发生例如验证的时候第一次验证失败,之后正确也不能提交的情况。 要如下设置:

<bean id="delUserAction" class="com.zpj.action.delUserAction" scope="prototype">
    <property name="userService" ref="userService"></property>
</bean

猜你喜欢

转载自blog.51cto.com/1197822/2157733