日志列表显示及分页实现
一.日志列表
1.在model里新建一个Diary类,然后在dao里新建一个DiaryDao类,写一个简单的属性是List<>的方法,diaryList()。
2.new一个 ArrayList<>()的对象diaryList,用stringBuffer获得sql查询
代码:
StringBuffer sb = new StringBuffer("select * from t_diary t1,t_diaryType t2 where t1.typeId = t2.diaryTypeId");
3.append一个根据发布时间降序的sql语句。(order by t1.releaseDate desc)
4.使用prepareStatement执行,参数为sb.toString,返回一个resultSet
5.如果resultSet里有值,则往一个新new的diary里填充获得的数据diaryId、title、content。
6.添加一个StringUtil和DateUtil。StringUtil是用来判断字符串是空或者不是空,DateUtil是用simpleDateFormat根据格式化来把日期对象转化为string对象,把s
1.在model里新建一个Diary类,然后在dao里新建一个DiaryDao类,写一个简单的属性是List<>的方法,diaryList()。
2.new一个 ArrayList<>()的对象diaryList,用stringBuffer获得sql查询
代码:
StringBuffer sb = new StringBuffer("select * from t_diary t1,t_diaryType t2 where t1.typeId = t2.diaryTypeId");
3.append一个根据发布时间降序的sql语句。(order by t1.releaseDate desc)
4.使用prepareStatement执行,参数为sb.toString,返回一个resultSet
5.如果resultSet里有值,则往一个新new的diary里填充获得的数据diaryId、title、content。
6.添加一个StringUtil和DateUtil。StringUtil是用来判断字符串是空或者不是空,DateUtil是用simpleDateFormat根据格式化来把日期对象转化为string对象,把s