后台数据库以yqcs_lsy为例:数据表如下(表中字段较多,未能展示完全)
采用MVC结构进行开发:
本文的写作环境在数据库可以连接之后
1.模型层
新建类YqcsLsy,没多少好说的,就是常规的变量定义,构造函数和get,set方法,含有参数的构造函数会在以后的业务中调用
public class YqcsLsy {
private Integer id;
private String name;
private String type;
private Double width;
private Double bottom;
private Double top;
private Double height;
private String pile;
private Double wheelbase;
private Double elevation;
private String location;
private Double groovewidth;
private Double grooveheight;
private Date date;
private String tip;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Double getWidth() {
return width;
}
public void setWidth(Double width) {
this.width = width;
}
public Double getBottom() {
return bottom;
}
public void setBottom(Double bottom) {
this.bottom = bottom;
}
public Double getTop() {
return top;
}
public void setTop(Double top) {
this.top = top;
}
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
public String getPile() {
return pile;
}
public void setPile(String pile) {
this.pile = pile;
}
public Double getWheelbase() {
return wheelbase;
}
public void setWheelbase(Double wheelbase) {
this.wheelbase = wheelbase;
}
public Double getElevation() {
return elevation;
}
public void setElevation(Double elevation) {
this.elevation = elevation;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Double getGroovewidth() {
return groovewidth;
}
public void setGroovewidth(Double groovewidth) {
this.groovewidth = groovewidth;
}
public Double getGrooveheight() {
return grooveheight;
}
public void setGrooveheight(Double grooveheight) {
this.grooveheight = grooveheight;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
public YqcsLsy(Integer id, String name, String type, Double width, Double bottom, Double top, Double height,
String pile, Double wheelbase, Double elevation, String location, Double groovewidth, Double grooveheight,
Date date, String tip) {
super();
this.id = id;
this.name = name;
this.type = type;
this.width = width;
this.bottom = bottom;
this.top = top;
this.height = height;
this.pile = pile;
this.wheelbase = wheelbase;
this.elevation = elevation;
this.location = location;
this.groovewidth = groovewidth;
this.grooveheight = grooveheight;
this.date = date;
this.tip = tip;
}
public YqcsLsy(String name, String type, Double width, Double bottom, Double top, Double height, String pile,
Double wheelbase, Double elevation, String location, Double groovewidth, Double grooveheight, Date date,
String tip) {
super();
this.name = name;
this.type = type;
this.width = width;
this.bottom = bottom;
this.top = top;
this.height = height;
this.pile = pile;
this.wheelbase = wheelbase;
this.elevation = elevation;
this.location = location;
this.groovewidth = groovewidth;
this.grooveheight = grooveheight;
this.date = date;
this.tip = tip;
}
@Override
public String toString() {
return "YqcsLsy [id=" + id + ", name=" + name + ", type=" + type + ", width=" + width + ", bottom=" + bottom
+ ", top=" + top + ", height=" + height + ", pile=" + pile + ", wheelbase=" + wheelbase + ", elevation="
+ elevation + ", location=" + location + ", groovewidth=" + groovewidth + ", grooveheight="
+ grooveheight + ", date=" + date + ", tip=" + tip + "]";
}
public YqcsLsy() {
}
//分页查询
private int pageNo;
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
//根据名称分页查询
public YqcsLsy(String name,int pageNo){
this.name=name;
this.pageNo=pageNo;
}
}
2.控制层(写sql语句,获取数据库的数据)
对于仪器参数,目前只要做这一些最基本的操作
YqcsLsyDao层结构
public interface YqcsLsyDao {
//前台通过下拉列表查询数据用
public List<YqcsLsy> getLsyByName(String name);
//获取下拉列表里的数据
public List<YqcsLsy> getAllName();
//查询结果分页显示
public List<YqcsLsy> getPageList(YqcsLsy yqcsLsy,