建一个动态Web工程和三张表:
表一:t_employee 字段:e_id,e_name,e_birthday,e_job
以下为二级联动所需的表
表二:t_city 字段:id,cityName,countryId(外键连接表三)
表三:t_country 字段:c_id,c_name
按图中所示建包和类还有接口页面等,下面是详细的页面代码
package com.lovo.bean;
public class CityBean {
private int id;
private String cityName;
private int countryId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public int getCountryId() {
return countryId;
}
public void setCountryId(int countryId) {
this.countryId = countryId;
}
@Override
public String toString() {
return "CityBean [id=" + id + ", cityName=" + cityName + ", countryId=" + countryId + "]";
}
}
package com.lovo.bean;
public class CountryBean {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "CountryBean [id=" + id + ", name=" + name + "]";
}
}
package com.lovo.bean;
import java.util.ArrayList;
import java.util.List;
public class CutPageBean<T> {
/**当前页需要显示的数据*/
private List<T> list = new ArrayList<T>();
/**总记录数*/
private int count;
/**总页数*/
private int totalPage;
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
@Override
public String toString() {
return "CutPageBean [list=" + list + ", count=" + count + ", totalPage=" + totalPage + "]";
}
}
package com.lovo.bean;
import java.sql.Date;
public class EmployeeBean {
private int id;
private String name;
private Date birthday;
private String job;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public EmployeeBean() {
super();
// TODO Auto-generated constructor stub
}
public EmployeeBean(String name, Date birthday, String job) {
super();
this.name = name;
this.birthday = birthday;
this.job = job;