⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.jsp

📁 LyNews凌云新闻系统
💻 JSP
字号:
<%
/*##################################################################**
**#  项目名称:LyNews『凌云新闻』                                  #**
**#                                                                #**
**#  程序开发: teddy 『星语凌』                                    #**
**#                                                                #**
**#  版权所有: 凌云创作室 (原流星电脑工作室)                       #**
**#                                                                #**
**#  主页地址: http://www.lybbs.com                                #**
**#            http://www.lybbs.net                                #**
**#  电邮地件: horseye@sina.com                                    #**
**#                                                                #**
**##################################################################*/
%>
<%@ include file="include/config.jsp"%>
<%@ page contentType="text/html;charset=GBK"%>

<%
ParameterUtils.setCharacterEncoding(request);
int boardID=ParameterUtils.getInt(request,"boardID");
int boardParentID=ParameterUtils.getInt(request,"boardParentID");
if(boardID==0 || boardParentID==0) {
  response.sendRedirect("errorPage.jsp");
  return;
}

//int boardParentID=20;

Factory factory = Factory.getInstance();
NewsFactory newsFactory = factory.getNewsFactory();
BoardFactory boardFactory = factory.getBoardFactory();
//分页变量定义
int e=30;                  //'每页显示的记录数
int totalpage=0;           //'页面总数
int pages=1;               //'显示的当前页面
int count=0;               //'库中数据的总记录数
int from=0,to=0;           //'从from篇到to篇
int p=0;                   //'数据库查询从p开始
//取页数
pages=ParameterUtils.getInt(request,"pages");
//分页预备
count=newsFactory.count(boardID);
totalpage=((count%e==0)?(count/e):(count/e+1));
if(totalpage==0) totalpage=1;
if(pages>totalpage) pages=totalpage;
else if(pages<1) pages=1;
if(count!=0)
   from=(pages-1)*e+1;
if(totalpage==pages)
   to=count;
else if(count!=0)
   to=from+e-1;
p= (pages-1)*e;

Iterator newsIterator = newsFactory.list(boardID,pages,e),
         boardIterator = boardFactory.list(boardParentID),
         boardParentIterator;
Board boardParent=boardFactory.board(boardParentID);
String boardParentName=boardParent.getBoardName();
Board board=boardFactory.board(boardID);
String boardName=board.getBoardName();

%>
<%@include file="include/head.jsp"%>
<script language="JavaScript">
function changePages(){
  var URL = document.changepages.pages.options[document.changepages.pages.selectedIndex].value;
  location.href = URL; target = '_self';
}
</script>

<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=760>
  <TR>
    <TD height=20>
      ※您现在的位置:<A href="index.jsp" class=list>首 页</A> → <A href="catalog.jsp?boardParentID=<%=boardParentID%>" class=list><%=boardParentName%></A> → <A href="list.jsp?boardParentID=<%=boardParentID%>&boardID=<%=boardID%>" class=list> <%=boardName%></A> → 文章列表 </FONT>
    </TD>
  </TR>
</TABLE>

<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=760 style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid">
  <TBODY>
  <TR>
    <!--change color #85b866 to #FFCC99-->
    <TD bgColor=#ffcc99 rowSpan=2 vAlign=top width=168>
      <TABLE border=0 cellPadding=0 cellSpacing=0 width=100%>
        <TR>
         <!--change color #44672e to #FF9966-->
         <TD align=center bgcolor=#ff9966><b><font color=#FFFFFF>相关文章</font></b></TD>
        </TR>
        <TR>
          <!--change color #e8fcdb to #FFFFc6-->
          <TD bgColor=#ffffc6>
            <ul>
<%
                while(boardIterator.hasNext()) {
                  board = (Board)boardIterator.next();
                  out.println("<li><a class=list href='list.jsp?boardParentID="+boardParentID+"&boardID="+board.getID()+"'>"+board.getBoardName()+"</a></li>");
                }
%>
            </ul>
          </TD>
        </TR>
      </TABLE>
<%
                  ClassCounterFactory classCounterFactory = new ClassCounterFactory();
                  classCounterFactory.setClassID(boardID);
                  classCounterFactory.setNowHour(GetDate.getHour());
                  ClassCounter classCounter=classCounterFactory.getMsg();
                  String today = GetDate.getStringDateShort();
                  if(today==null)
                    today = "";
                  if(!today.equals(classCounter.getRecordDate())) {
                    classCounterFactory.update(today);
                  }
                  else {
                    classCounterFactory.add();
                  }
%>
    </TD>
    <TD vAlign=top>
      <TABLE bgColor=#656565 border=0 borderColorDark=#ffffff borderColorLight=#008000 cellSpacing=1 width="100%">
        <TBODY>
        <TR bgColor=#eeeeee>
          <TD height=22 width="80%" align=center><B>文&nbsp;章&nbsp;名</B></TD>
          <TD height=22 width="20%" align=center><B>发布日期</B></TD>
        </TR>
<%
        News news;
        while(newsIterator.hasNext()) {
	  news = (News)newsIterator.next();
%>
        <TR>
          <TD bgColor=#ffffff height=20 width="80%">
            <A class=list href="news/<%=news.getNewsFile()%>" target=_blank><%=news.getTitle()%></A>
          </TD>
          <TD bgColor=#ffffff width="20%" align=center>
<%
          Date date =new Date(news.getDate());
          SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
          out.println(formatter.format(date));
%>
          </TD>
        </TR>
<%
        }
%>
       </TBODY>
      </TABLE>
    </TD>
  </TR>
  <TR>
   <TD>
    <table cellpadding=0 cellspacing=2 width=100% align=center>
     <form name=changepages>
     <tr>
       <td>
            共<b><%=totalpage%></b>页
            当前第<b><%out.print(from+"-"+to);%></b>个
            第<b><%=pages%></b>页
       </td>
<%
if(totalpage>1) {
%>
  <td>
           <A href=list.jsp?boardParentID=<%=boardParentID%>&boardID=<%=boardID%>&pages=1><IMG alt=首页 border=0 src=images/first.gif width=11 height=10></A>&nbsp;
           <A href=list.jsp?boardParentID=<%=boardParentID%>&boardID=<%=boardID%>&pages=<%=(pages<2)?pages:(pages-1)%>><IMG alt=上一页 border=0 src=images/previous.gif width=11 height=10></A>&nbsp;
           <A href=list.jsp?boardParentID=<%=boardParentID%>&boardID=<%=boardID%>&pages=<%=(pages>totalpage-1)?totalpage:(pages+1)%>><IMG alt=下一页 border=0 src=images/next.gif width=11 height=10></A>&nbsp;
           <A href=list.jsp?boardParentID=<%=boardParentID%>&boardID=<%=boardID%>&pages=<%=totalpage%>><IMG alt=末页 border=0 src=images/last.gif width=11 height=10></A>&nbsp;
  </td>
  <td>
      <SELECT name=pages size=1 onchange="changePages()">
<%
        int pagesFrom=1,pagesTo=totalpage;
        if(pages<=5 && totalpage-pages>5)
          pagesTo=totalpage>=10?10:totalpage;
        else if(pages>5 && totalpage-pages>5) {
          pagesFrom=pages-4;
          pagesTo=pages+5;
        }
        else if(pages>5 && totalpage-pages<=5)
          pagesFrom=totalpage>=10?totalpage-9:1;
        if(pagesFrom!=1)
          out.println("<OPTION value='list.jsp?boardParentID="+boardParentID+"&boardID="+boardID+"&pages="+pagesFrom+"'>--more--</OPTION>");
        for(int i=pagesFrom;i<=pagesTo;i++) {
           if(i==pages) {
              out.println("<OPTION value='list.jsp?boardParentID="+boardParentID+"&boardID="+boardID+"&pages="+i+"' selected>第"+i+"页</OPTION>");
           }
           else
              out.println("<OPTION value='list.jsp?boardParentID="+boardParentID+"&boardID="+boardID+"&pages="+i+"'>第"+i+"页</OPTION>");
        }
        if(pagesTo!=totalpage)
          out.println("<OPTION value='list.jsp?boardParentID="+boardParentID+"&boardID="+boardID+"&pages="+pagesTo+"'>--more--</OPTION>");
%>
      </SELECT>
  </td>
<%
}
%>
     </form>
     </tr>
    </table>
   </TD>
  </TR>
  </TBODY>
</TABLE>
<%@include file="include/foot.jsp"%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -