<%@page import="cn.pb.news.util.PageSupport"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cn.pb.news.entity.News"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../common/common.jsp" %>
<script type="text/javascript">
var flag = '${param.flag}';
if(flag != null && flag != '' && flag != undefined) {
if(flag == 'success') {
alert('删除成功');
}else if(flag == 'failed') {
alert('删除失败');
}
}
function addNews() {
window.location = "newsDetailCreateSimple.jsp";
}
function page_nav(frm,num) {
frm.pageIndex.value = num;
frm.submit();
}
</script>
<div class="main-content-right">
<!--即时新闻-->
<div class="main-text-box">
<div class="main-text-box-tbg">
<div class="main-text-box-bbg">
<form name ="searchForm" id="searchForm" action="/news/jsp/admin/newsDetailList.jsp" method="post">
<div>
新闻分类:
<select name="categoryId">
<option value="0">全部</option>
<option value='1' >国内</option>
<option value='2' >国际</option>
<option value='3' >娱乐</option>
<option value='4' >军事</option>
<option value='5' >财经</option>
<option value='6' >天气</option>
</select>
新闻标题<input type="text" name="title" id="title" value=''/>
<button type="submit" class="page-btn">GO</button>
<button type="button" onclick="addNews();" class="page-btn">增加</button>
<input type="hidden" id="pageIndex" name="pageIndex" value="1"/>
</div>
</form>
<table cellpadding="1" cellspacing="1" class="admin-list">
<thead >
<tr class="admin-list-head">
<th>新闻标题</th>
<th>作者</th>
<th>时间</th>
<th>操作</th>
</tr>
</thead>
<%
int pageSize = 2;
String pageIndex = request.getParameter("pageIndex");
int currentPageNo;
if(pageIndex == null) {
currentPageNo = 1;
}else{
currentPageNo = Integer.parseInt(pageIndex);
}
//总记录数
int totalCount = newsService.getTotalCount();
//总页数
PageSupport ps = new PageSupport();
ps.setPageSize(pageSize);
ps.setCurrentPageNo(currentPageNo);
ps.setTotalCount(totalCount);
int totalPageCount = ps.getTotalPageCount();
//首页尾页的异常控制
if(currentPageNo < 1){
currentPageNo = 1;
}
if(currentPageNo > totalPageCount){
currentPageNo = totalPageCount;
}
List<News> newsList=newsService.getPageNewsList(currentPageNo,pageSize);
int i=0;
for(News news:newsList){
i++;
%>
<tbody>
<tr <%if(i % 2 != 0){%>class="admin-list-td-h2"<%} %>>
<td><a href='adminNewsView.jsp?id=2'><%=news.getTitle() %></a></td>
<td><%=news.getAuthor()%></td>
<td><%=new SimpleDateFormat("yyyy-MM-dd").format(news.getCreateDate()) %></td>
<td>
<a href='adminNewsCreate.jsp?id=2'>修改</a>
<a href="javascript:if(confirm('确认是否删除此新闻?')) location='adminNewsDel.jsp?id=2'">删除</a>
</td>
</tr>
</tbody>
<%
}
%>
</table>
<div class="page-bar">
<ul class="page-num-ul clearfix">
<li>共<%=totalCount %>条记录 <%=currentPageNo %>/<%=totalPageCount %>页</li>
<%if(currentPageNo > 1) { %>
<a href="javascript:page_nav(document.forms[0],1)">首页</a>
<a href="javascript:page_nav(document.forms[0],<%=currentPageNo-1%>)">上一页</a>
<% }
if(currentPageNo < totalPageCount) { %>
<a href="javascript:page_nav(document.forms[0],<%=currentPageNo+1%>)">下一页</a>
<a href="javascript:page_nav(document.forms[0],<%=totalPageCount%>)">最后一页</a>
<% } %>
</ul>
<span class="page-go-form"><label>跳转至</label>
<input type="text" name="inputPage" id="inputPage" class="page-key" />页
<button type="button" class="page-btn" onClick="">GO</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
拖鞋_
相关分类