struts 一句话获得表单所有数据

struts1  ,从表单上获取数据多的话,很麻烦,一次获得数据有很多方法 ,下面用户注册为例

.....省略包

import org.apache.struts.util.RequestUtils

 

public class RegisterAction extends BaseAction
{
  public ActionForward createUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
  {
    String flag = "false";
    User user = new User();
    RequestUtils.populate(user, request);

 

   ......

    request.setAttribute("flag", flag);

    return mapping.findForward("createuser");

}

 

 

RequestUtils.populate(user, request);实现所有用户的数据从表单获取

 

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Set;

public class User
{
  private String userId;
  private String nickname;
  private String password;
  private String email;
  private String question;
  private String answer;
  private String duty;
  private String degree;
  private String company;
  private String phone;
  private String birthday;
  private String city;
  private String interest;
  private Timestamp createTime;
  private String system;
  private Timestamp lastVisitTime;
  private Integer visitTimes;
  private HashMap groups;
  private HashMap roles;
  private Set hotTopics;
  private Set consults;
  private Acl acl;

  public User()
  {
    this.groups = new HashMap();
    this.roles = new HashMap();
    this.acl = new Acl();
  }

  public String getUserId()
  {
    return this.userId;
  }

  public void setUserId(String userId)
  {
    this.userId = userId;
  }

  public String getPassword()
  {
    return this.password;
  }

  public void setPassword(String password)
  {
    this.password = password;
  }

  public Acl getAcl()
  {
    return this.acl;
  }

  public void setAcl(Acl acl)
  {
    this.acl = acl;
  }

  public String getAnswer()
  {
    return this.answer;
  }

  public void setAnswer(String answer)
  {
    this.answer = answer;
  }

  public String getBirthday()
  {
    return this.birthday;
  }

  public void setBirthday(String birthday)
  {
    this.birthday = birthday;
  }

  public String getCity()
  {
    return this.city;
  }

  public void setCity(String city)
  {
    this.city = city;
  }

  public String getCompany()
  {
    return this.company;
  }

  public void setCompany(String company)
  {
    this.company = company;
  }

  public Timestamp getCreateTime()
  {
    return this.createTime;
  }

  public void setCreateTime(Timestamp createTime)
  {
    this.createTime = createTime;
  }

  public String getDegree()
  {
    return this.degree;
  }

  public void setDegree(String degree)
  {
    this.degree = degree;
  }

  public String getDuty()
  {
    return this.duty;
  }

  public void setDuty(String duty)
  {
    this.duty = duty;
  }

  public String getEmail()
  {
    return this.email;
  }

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

  public String getInterest()
  {
    return this.interest;
  }

  public void setInterest(String interest)
  {
    this.interest = interest;
  }

  public Timestamp getLastVisitTime()
  {
    return this.lastVisitTime;
  }

  public void setLastVisitTime(Timestamp lastVisitTime)
  {
    this.lastVisitTime = lastVisitTime;
  }

  public String getNickname()
  {
    return this.nickname;
  }

  public void setNickname(String nickname)
  {
    this.nickname = nickname;
  }

  public HashMap getGroups()
  {
    return this.groups;
  }

  public void setGroups(HashMap groups)
  {
    this.groups = groups;
  }

  public String getPhone()
  {
    return this.phone;
  }

  public void setPhone(String phone)
  {
    this.phone = phone;
  }

  public String getQuestion()
  {
    return this.question;
  }

  public void setQuestion(String question)
  {
    this.question = question;
  }

  public HashMap getRoles()
  {
    return this.roles;
  }

  public void setRoles(HashMap roles)
  {
    this.roles = roles;
  }

  public Integer getVisitTimes()
  {
    return this.visitTimes;
  }

  public void setVisitTimes(Integer visitTimes)
  {
    this.visitTimes = visitTimes;
  }

  public String getSystem()
  {
    return this.system;
  }

  public void setSystem(String system)
  {
    this.system = system;
  }

  public Set getHotTopics()
  {
    return this.hotTopics;
  }

  public void setHotTopics(Set hotTopics)
  {
    this.hotTopics = hotTopics;
  }

  public Set getConsults()
  {
    return this.consults;
  }

  public void setConsults(Set consults)
  {
    this.consults = consults;
  }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值