<%@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">? ? ? ? <!--即時(shí)新聞-->? ? ? ? <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' >國內(nèi)</option> ? ? ? ? ? ? ? ? <option value='2' >國際</option> ? ? ? ? ? ? ? ? <option value='3' >娛樂</option> ? ? ? ? ? ? ? ? <option value='4' >軍事</option> ? ? ? ? ? ? ? ? <option value='5' >財(cái)經(jīng)</option> ? ? ? ? ? ? ? ? <option value='6' >天氣</option> ? ? ? ? ? ? ? ? </select> 新聞標(biāo)題<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>新聞標(biāo)題</th>? ? ? ? ? ? ? ? ? ? ? ? <th>作者</th>? ? ? ? ? ? ? ? ? ? ? ? <th>時(shí)間</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);? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? //總記錄數(shù)? ? ? ? ? ? ? ? int totalCount = newsService.getTotalCount();? ? ? ? ? ? ? ? //總頁數(shù)? ? ? ? ? ? ? ? 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('確認(rèn)是否刪除此新聞?')) 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>跳轉(zhuǎn)至</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>
JSP頁面404錯(cuò),點(diǎn)擊分頁的按鈕就報(bào)錯(cuò)
fenkapian
2016-10-07 07:51:54