加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

如何使用Stripes清除bean字段

发布时间:2020-12-15 00:39:00 所属栏目:Java 来源:网络整理
导读:在JSP中,我有以下字段: stripes:text name="email"/ 这个字段在我的动作bean(片段)中: public class CreateClaim implements ActionBean { private String email; public void setEmail(String email) { this.email = email; } public String getEmail() {
在JSP中,我有以下字段:
<stripes:text name="email"/>

这个字段在我的动作bean(片段)中:

public class CreateClaim implements ActionBean {

    private String email;

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail() {
        return email;
    }

    public Resolution alc(){
        email = "poodle";
        return new ForwardResolution("aForward.jsp");
    }

}

在alc()方法中,我将电子邮件设置为null.但是当页面呈现时,电子邮件字段的值与最初输入的完全相同.
有没有办法清除此字段一次并触发事件?

干杯

戴夫

解决方法

这与Stripes框架的人口策略有关.默认情况下,它具有请求优先策略(由于与早期版本的向后兼容性),但我总是将其更改为 bean first population strategy.

只需编辑web.xml即可为Stripes过滤器添加init-param:

<filter>
  <filter-name>StripesFilter</filter-name>
    <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>

    <init-param>
      <param-name>PopulationStrategy.Class</param-name>
      <param-value>
        net.sourceforge.stripes.tag.BeanFirstPopulationStrategy
      </param-value>
    </init-param>
..etc...

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读