<body>
<%
List<ChatRecord> chatRecords = (List) request
.getAttribute("chatRecords");
%>
<form action="manageRecord.do" method="post">
<div class="all">
<span class="title">聊天记录管理</span>
<div class="content">
选择客服:
<select name="server">
<option value="" selected="selected">
全部客服
</option>
<option value="">
vicente
</option>
</select>
<br>
对话时间:
<input type="text" name="time1" id="time1"
onclick="MyCalendar.SetDate(this)" />

<input type="text" name="time1" id="time2"
onclick="MyCalendar.SetDate(this)">
<br />
<input type="submit" value="查询" style="margin-top: 15px;">
</div>
<div class="count">
<div id="c1" style="display: none;">
<table width="800" border="1">
<tr>
<th>
客服名称
</th>
<th>
聊天内容
</th>
<th>
聊天日期
</th>
</tr> <td></td>
<td></td>
<td></td>
</table>
</div>
<div class="c2">
<input type="checkbox" />
全选&nbsp;&nbsp;
<input type="button" value="删除" />
</div>
</div>
</div>
</form> </body>public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
String time1 = request.getParameter("time1");
String time2 = request.getParameter("time2");
Date chatCreateTime1 = null;
Date chatCreateTime2 = null;
try {
chatCreateTime1 = dateformat.parse(time1);
chatCreateTime2 = dateformat.parse(time2);
} catch (ParseException e) {
e.printStackTrace();
}
List<ChatRecord> chatRecords = chatRecordBo.getRecords(chatCreateTime1,chatCreateTime2);
if(chatRecords != null){
request.setAttribute("list", chatRecords);
request.getRequestDispatcher("/adminFunction/manageRecord.jsp").forward(request, response);
}else{
response.sendRedirect("/index.jsp");
}
}
public List<ChatRecord> getChatRecords(Date chatCreateTime1,
Date chatCreateTime2) {
ArrayList<ChatRecord> chatRecords = new ArrayList<ChatRecord>();
String sql = "select * from chatRecord where ChatCreateTime  between"
+ chatCreateTime1 + "and" + chatCreateTime2;
Connection conn = DBConnection.getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
ChatRecord chatRecord = new ChatRecord();
chatRecord.setChatId(rs.getInt(1));
chatRecord.setServerName(rs.getString(2));
chatRecord.setChatContent(rs.getString(3));
chatRecord.setChatCreateTime(rs.getDate(4));
chatRecords.add(chatRecord);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBConnection.closeAll(rs, pstmt, conn);
}
return chatRecords;
}