struts除去上次提交的值

来源:互联网 发布:php修改ad用户源代码 编辑:程序博客网 时间:2024/05/16 13:41

struts当第二次提交数据时,发现还保留了第一的一些数据,那是因为struts的默认设置范围是session,也就是说本次会话的数据都将保留,只能替换。

如果不想不留上次提交的数据只需要将范围设置成request就可以了

方法:找到项目中的struts配置文件struts-config.xml,在里面找到相应的action,在里面加上scope="request"就可以了,如

<action-mappings>
    <!-- struts清除上次提交的数据   scope="request"     -->
    <!-- 默认放在session中 -->
      <action path="/power"  type="action.FunctionADD" scope="request"  name="fuctionAdd">
       <forward name="success" path="/Power.jsp"></forward>
      </action>
      <action path="/roleAdd" type="action.RoleAdd" scope="request" name="addRole">
       <forward name="success" path="/Power.jsp"></forward>
      </action>
    </action-mappings>