分页和二级联动

本文展示了如何在Java Web环境中实现分页和二级联动功能。通过创建多个类和接口,包括EmployeeBean、CityBean和CountryBean,以及对应的DAO和Service层,实现了数据的查询和分页展示。此外,利用jQuery进行AJAX请求,动态更新二级联动下拉菜单的内容,实现了根据国家选择城市的效果。最后,给出了前端JSP页面的HTML和JavaScript代码,用于展示分页和联动效果。
摘要由CSDN通过智能技术生成

建一个动态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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值