惯例广告一发,对于初学真,真的很有用www.java1234.com,去试试吧!

1、建立数据表及数据(略)

2、创建student model
package com.java1234.model; import java.sql.Date; public class Student { private int id;
private String stuNo;
private String stuName;
private String sex;
private Date birthday;
private int gradeId;
private String email;
private String stuDesc; public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getStuNo() {
return stuNo;
}
public void setStuNo(String stuNo) {
this.stuNo = stuNo;
}
public String getStuName() {
return stuName;
}
public void setStuName(String stuName) {
this.stuName = stuName;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public int getGradeId() {
return gradeId;
}
public void setGradeId(int gradeId) {
this.gradeId = gradeId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getStuDesc() {
return stuDesc;
}
public void setStuDesc(String stuDesc) {
this.stuDesc = stuDesc;
} } 3、查询dao
public ResultSet studentList(Connection con,PageBean pageBean)throws Exception{
StringBuffer sb=new StringBuffer("select * from t_student s,t_grade g where s.gradeId=g.id");
if(pageBean!=null){
sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows());
}
PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where"));
return pstmt.executeQuery();
} public int studentCount(Connection con)throws Exception{
StringBuffer sb=new StringBuffer("select count(*) as total from t_student s,t_grade g where s.gradeId=g.id");
PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs=pstmt.executeQuery();
if(rs.next()){
return rs.getInt("total");
}else{
return 0;
}
} 4、日期报错
public static String formatDate(Date date,String format){
String result="";
SimpleDateFormat sdf=new SimpleDateFormat(format);
if(date!=null){
result=sdf.format(date);
}
return result;
} if(o instanceof Date){
mapOfColValues.put(md.getColumnName(i),DateUtil.formatDate((Date)o, "yyyy-MM-dd"));
}else{
mapOfColValues.put(md.getColumnName(i),rs.getObject(i));
} 5、查询表单
<div>
&nbsp;学号:&nbsp;<input type="text" name="s_stuNo" id="s_stuNo" size="10" />
&nbsp;姓名:&nbsp;<input type="text" name="s_stuNo" id="s_stuNo" size="10" />
&nbsp;性别:&nbsp;<select class="easyui-combobox" id="s_sex" name="s_sex" editable="false" panelHeight="auto" >
<option value="" >请选择</option>
<option value="男" >男</option>
<option value="女" >女</option>
</select>
&nbsp;出生日期:&nbsp;<input type="text" class="easyui-datebox" name="s_bbirthday" id="s_bbirthday" size="11" editable="false" />->
<input type="text" class="easyui-datebox" name="s_ebirthday" id="s_ebirthday" size="11" editable="false" />
&nbsp;所属班级:&nbsp;<input class="easyui-combobox" id="s_gradeId" name="s_gradeId" size="11" data-options="editable:false,valueField:'id',textField:'gradeName',url:'gradeComboList'" />
<a href="javascript:searchStudent()" class="easyui-linkbutton" iconCls="icon-search" plain="true" >搜索</a>
</div> 6、ComboList
Connection con=null;
try {
con=dbUtil.getCon();
JSONArray jsonArray=new JSONArray();
JSONObject jsonObject=new JSONObject();
jsonObject.put("id", "");
jsonObject.put("gradeName", "请选择");
jsonArray.add(jsonObject);
jsonArray.addAll(JsonUtil.formatRsToJsonArray(gradeDao.gradeList(con, null,null)));
ResponseUtil.write(response, jsonArray);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

最新文章

  1. hadoop常用的操作命令
  2. Html5 杂记
  3. mysql: see all open connections to a given database?
  4. 如何去除My97 DatePicker控件上右键弹出官网的链接 - 如何debug混淆过的代码
  5. iphone删除自动更新的系统
  6. html5---webworker多线程
  7. Rules
  8. C++类訪问控制及继承
  9. Code First 数据注释--DatabaseGenerated
  10. 全局获取Context的技巧
  11. 【前端,干货】react and redux教程学习实践(二)。
  12. CentOS 7 服务器配置--安装Mysql
  13. [转载] su和sudo
  14. 如何在ubuntu中安装php
  15. Webapi创建和使用 以及填坑(三)
  16. bzoj2086: [Poi2010]Blocks DP,单调栈
  17. 使用C#读取网站相对路径文件夹下所有图片
  18. 菜鸟如何使用hanlp做分词的过程记录
  19. java中原生的发送http请求(无任何的jar包导入)
  20. Mac下显示和隐藏隐藏文件的命令

热门文章

  1. Win(Phone)10开发第(2)弹,导出APPX包并签名部署
  2. MySQL中需要注意的几点
  3. *p++与(*p)++与*(p++)------自增运算符常见误区
  4. JDK源码学习之 集合实现类
  5. iOS-构建自己的代码块【提高编码效率-Xcode代码块】
  6. JS: 数据结构与算法之栈
  7. POJ 1287
  8. Hive导出表数据
  9. Java之集合(十二)TreeMap
  10. Liunx安装Git