1. 程式人生 > >JavaBean的部分用法(一)

JavaBean的部分用法(一)

這個實體類是javabean

package com.zdsoft.bean;

/**
* javabean+jsp的聯合使用
* @author liuyegonghzi
*
*/
public class TestBean
{
private String username;
private String password;
private String sex;
private Integer age;
private String birthday;
private String[] hobby;
private String hobbys=”“;
/**
* @return the username
*/
public String getUsername()
{
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username)
{
this.username = username;
}
/**
* @return the sex
*/
public String getSex()
{
return sex;
}
/**
* @param sex the sex to set
*/
public void setSex(String sex)
{
this.sex = sex;
}
/**
* @return the age
*/
public Integer getAge()
{
return age;
}
/**
* @param age the age to set
*/
public void setAge(Integer age)
{
this.age = age;
}
/**
* @return the birthday
*/
public String getBirthday()
{
return birthday;
}
/**
* @param birthday the birthday to set
*/
public void setBirthday(String birthday)
{
this.birthday = birthday;
}
/**
* @return the hobby
*/
public String[] getHobby()
{
return hobby;
}
/**
* @param hooby the hobby to set
*/
public void setHobby(String[] hobby)
{
this.hobby = hobby;
}
/**
* @return the hobbys
*/
public String getHobbys()
{
if(this.hobby.length>0){
for(String str:hobby){
this.hobbys+=str+”,”;
}
this.hobbys=hobbys.substring(0, hobbys.length()-1);
}
return hobbys;
}
/**
* @param hobbys the hobbys to set
*/
public void setHobbys(String hobbys)
{
this.hobbys = hobbys;
}
/**
* @return the password
*/
public String getPassword()
{
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password)
{
this.password = password;
}

}

表單jsp