?? new.jsp
字號:
<%--這個頁面是用來顯示除了內容之外的所有新聞的--%>
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="oanoticecrud.newsBean"%>
<jsp:useBean id="pagecount" class="oabean.pageInfo" scope="page" />
<jsp:useBean id="getPages" class="oabean.pages" scope="page" />
<jsp:useBean id="date" class="oabean.date" scope="page" />
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>show news info</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css" media="all">
@import "admin/Upimg/thickbox.css";
@import "css/pages.css";
</style>
<script src="admin/Upimg/jquery-1.1.3.1.pack.js" type="text/javascript"></script>
<script src="admin/Upimg/thickbox-compressed.js" type="text/javascript"></script>
<script src="admin/Upimg/global.js" type="text/javascript"></script>
<script type="text/javascript" src="/oa/js/popcalendar.js"></script>
<script language="javascript">
function sty()
{
document.getElementById("add").style.textDecoration="underline";
}
function out()
{
document.getElementById("add").style.textDecoration="blink";
}
</script>
</head>
<body>
<%
String un=(String)session.getAttribute("user");
System.out.println(un);
if(un==null) {response.sendRedirect("../index.jsp");}
int pageNow=1;//初始頁
int pageSize=4;//一頁顯示多少條記錄
String s="";
String pagenow=request.getParameter("pageNow");//接收頁碼
//下面是獲取當前要顯示的是重要還是普通的新聞
String sel1=request.getParameter("select1");
String dat=request.getParameter("ndate");
if(pagenow!=null&&pagenow!="")
{
pageNow=Integer.parseInt(pagenow);
}
String sql= "select top "+pageSize+" * from oa_news where newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news )";
String Countsql="select count(*) from oa_news";
//這里是只查詢普通還是重要的新聞
if((sel1!=null&&sel1!="")&&dat=="")
{
if(sel1.equals("1"))
{
sql="select top "+pageSize+" * from oa_news where type='普通' and newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news where type='普通')";
Countsql="select count(*)from oa_news where type='普通'";
}
else if(sel1.equals("2"))
{
sql="select top "+pageSize+" * from oa_news where type='重要' and newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news where type='重要')";
Countsql="select count(*)from oa_news where type='重要'";
}
}
//查詢具體時間的公告
else if(sel1==""&&dat!="")
{
sql="select top "+pageSize+" * from oa_news where dateTime='"+dat+"' and newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news where dateTime='"+dat+"')";
Countsql="select count(*) from oa_news where dateTime='"+dat+"'";
}
//這里是查詢選了type和datetime的新聞
else if((sel1!=null&&sel1!="")&&dat!="" )
{
if(sel1.equals("1"))
{
sql="select top "+pageSize+" * from oa_news where type='普通' and dateTime='"+dat+"' and newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news where type='普通' and dateTime='"+dat+"')";
Countsql="select count(*) from oa_news where type='普通' and dateTime='"+dat+"'";
}
else if(sel1.equals("2"))
{
sql="select top "+pageSize+" * from oa_news where type='重要' and dateTime='"+dat+"' and newId not in(select top "+pageSize*(pageNow-1)+" newId from oa_news where type='重要' and dateTime='"+dat+"')";
Countsql="select count(*) from oa_news where type='重要' and dateTime='"+dat+"'";
}
}
int pageCount=pagecount.getpageCount(Countsql,pageSize);//得到總共有多少頁
int rowCount=pagecount.getrowCount(Countsql);//得到總共有多少條記錄
ArrayList a1=getPages.getNews(sql);//得到分頁信息
//顯示
%>
<form action="admin/new.jsp" method="post" name="student">
<table width="100%" class="topList" cellSpacing=1 align="center" border=0>
<tr>
<td align="center" colspan="10"><div align="center" class="STYLE3">
<select name="select1" size="1">
<option value="">請選擇重要程度</option>
<option value="1">普通</option>
<option value="2">重要</option>
</select>
<label>日期:</label>
<input id="sdv" name="ndate" onclick="showCalendar(this, this, 'yyyy-mm-dd','cn',1);" maxlength="20" size="10" value=""/>日
<script>
var osdv = document.getElementById('sdv');
if(osdv != null) osdv.readOnly='true';
</script>
<input type="submit" name="ns" value="搜索"></div>
</td>
</tr>
<tr>
<td scope="col"><div align="center" class="STYLE1">新聞號</div></td>
<td scope="col"><div align="center" class="STYLE1">標題</div></td>
<td scope="col"><div align="center" class="STYLE1">新聞類別</div></td>
<td scope="col"><div align="center" class="STYLE1">新聞時間</div></td>
<td scope="col" colspan="3"><div align="center" class="STYLE1">操作</div></td>
</tr>
<%
for(int i=0;i<a1.size();i++)
{
//從a1中取出noticeBean
oanoticecrud.newsBean St=(oanoticecrud.newsBean)a1.get(i);
%>
<tr>
<% int newid=St.getNewId();%>
<td align="center"><%=St.getNewId()%></td>
<td align="center"><a href="admin/newscontent.jsp?id=<%=newid%>&modal=true" class="thickbox" style="text-decoration:none"><%=St.getTitle()%></a></td>
<td align="center"><%=St.getType()%></td>
<td align="center"><%=St.getDateTime().substring(0,10)%></td>
<td align="center"><img src="images/del.gif"><a href="new/delnews.new?id=<%=newid%>" onclick="return window.confirm('您確認要刪除嗎?');" style="text-decoration:none">刪除</a></td>
<td align="center"><img src="images/mod.gif"><a href="admin/modnews.jsp?id=<%=newid%>&modal=true" class="thickbox" style="text-decoration:none">修改</a></td>
<%
}
%>
<tr>
<td colspan="10">
<ul id="nav">
共有<span class="STYLE2"><%=rowCount%></span>條記錄
<%
out.println("<li><a href=admin/new.jsp?pageNow=1&&select1="+sel1+"&&ndate="+dat+" style='text-decoration:none'>首</a></li>");
if(pageNow!=1)
{
out.println("<li><a href=admin/new.jsp?pageNow="+(pageNow-1)+"&&select1="+sel1+"&&ndate="+dat+" style='text-decoration:none'>«</a></li>");
}
for(int j=1;j<=pageCount;j++)
{
out.println("<li><a href=admin/new.jsp?pageNow="+j+"&&select1="+sel1+"&&ndate="+dat+" style='text-decoration:none'>["+j+"]</a></li>");
}
if(pageNow!=pageCount)
{
out.println("<li><a href=admin/new.jsp?pageNow="+(pageNow+1)+"&&select1="+sel1+"&&ndate="+dat+" style='text-decoration:none'>»</a></li>");
}
out.println("<li><a href=admin/new.jsp?pageNow="+pageCount+"&&select1="+sel1+"&&ndate="+dat+" style='text-decoration:none'>末</a></li>");
%>
<span class="STYLE2"><% out.println(pageNow+"/"+pageCount);%></span>
</ul>
</td>
<td align="left"><img src="images/add.gif"><a id="add" href="admin/addnews.jsp?modal=true" onmouseover="sty();" onmouseout="out();" style='text-decoration:blink'>增加</a></td>
</tr>
</table>
</form>
<form action="admin/new.jsp">
跳轉到第
<input type="text" name="pageNow" size="8">頁
<input type="hidden" name="select1" value="<%=sel1%>">
<input type="hidden" name="ndate" value="<%=dat%>">
<input type="submit" value="Go">
</form>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -