日期:2014-05-17 浏览次数:20782 次
<%
request.setCharacterEncoding("UTF-8");//设置编码
String strPageNum = request.getParameter("pageNum");//获得当前页数
int pageNum = 1;
//把当前页数的字符串转换为数字,如果失败则为1,即首页
try{
pageNum = Integer.parseInt(strPageNum);
}catch(Exception e){
pageNum = 1;
}
request.setAttribute("pageNum", pageNum);
ShowAllSongs showAllsongs = new ShowAllSongs();//实例化
showAllsongs.setCountRow();//设置总行数
showAllsongs.setCountPage();//设置总页数
int countPage = showAllsongs.getCountPage();//获得总页数
//如果当前页数小于 0 或者大于总页数,则把当前页重新设置为1
if(pageNum<=0 || pageNum>countPage){
pageNum = 1;
}
showAllsongs.setCurrentlyPage(pageNum);//设置当前页
int currentlyPage = showAllsongs.getCurrentlyPage();//获得当前页
List<Songs> songList = showAllsongs.getSongsPaginQuery(pageNum);
//分页查询
if(songList!=null){
%>
<table border="1" align="center">
<tr>
<td colspan="8">
歌曲名称:<input type="textbox"/><input type="button" value="查找"/>
<input type="button" value="编辑歌曲信息"/>
</td>
</tr>
<tr>
<th align="center">歌曲名称</th>
<th align="center">歌曲编号</th>
<th align="center">分类编号</th>
<th align="center">歌手</th>
<th align="center">加入时间</th>
<th align="center">频道</th>
<th align="center">点击率</th>
<th aling="center">操作</th>
</tr>
<%
for(int i = 0;i<songList.size();i++){
Songs songs = songList.get(i);
%>
<tr>
<td width="150"><%=songs.getTitle() %></td>
<td width="100"><%=songs.getSongid() %></td>
<td width="50"><%=songs.getTypeid() %></td>
<td width="100"><%=songs.getSinger() %></td>
<td width="100"><%=songs.getDateandtime() %></td>
<td width="50"><%=songs.getChannel() %></td>
<td width="100"><%=songs.getHits() %></td>
<td width="100" align="center"><input type="button" value="编辑" src="/servelet/editSongInfo"/></td>
</tr>
<%
}
%>
<tr>
<td colspan="8" align="center">
<%
if(currentlyPage==1){
%>
共<%=countPage %>页
当前第<%=currentlyPage %>页
<a href="showAllSongList.jsp?pageNum=1">首页</a>
上一页
<a href="showAllSongList.jsp?pageNum=<%=currentlyPage+1 %>">下一页</a>
<a href="showAllSongList.jsp?pageNum=<%=countPage %>">尾页</a>