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

📄 main.jsp

📁 《JSP通用模块及典型系统开发实例导航》源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include.jsp"%>
<%@ include file="session.jsp"%>
<%int classid =(null==request.getParameter("classid")?1:(Integer.parseInt(request.getParameter("classid"))));%>
<%int page1 = (null==request.getParameter("page")?1:(Integer.parseInt(request.getParameter("page"))));%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<meta http-equiv="refresh" content="60*30">
<title>欢迎光临<%=title%></title>
<link rel="stylesheet" href="../css/css.css" type="text/css" media="screen">
</head>
<body>
<TABLE bgColor=<%=tablebgcolor%> border=0 cellPadding=0 cellSpacing=1 width=100% align=CENTER>
	<TR><TD align=middle background=../img/index/topback.gif height=10>
	</TD></TR>
</TABLE>
<TABLE align=center border=0 cellPadding=6 cellSpacing=1 width=100% bgColor=<%=tablebgcolor%>>
	<TBODY>
	<TR>
		<TD bgColor=<%=tdbgcolor2%> colspan=3 align=center><FONT SIZE="3" COLOR="#ffffff"><B>后台管理</B></FONT></TD>
	</TR>
	<TR>
		<TD bgColor=<%=tdbgcolor2%> colspan=3><A HREF="addnews.jsp">添加新闻</A>
		&nbsp;&nbsp;<A HREF="mastermanage.jsp">管理员管理</A>(系统管理员专用)
		&nbsp;&nbsp;<A HREF="classmanage.jsp">栏目管理</A>(系统管理员专用)
		&nbsp;&nbsp;<A HREF="logout.jsp">退出</A>
		&nbsp;&nbsp;<A HREF="javascript:this.location.reload()">刷新</A>
		&nbsp;&nbsp;<A HREF="../index.jsp">主页</A></TD>
	</TR>
	<TR>
		<TD bgColor=<%=tdbgcolor2%> colspan=2 width=70%>
		<form name="myform">
			<select name="select" size="1" onchange="location=this.options[this.selectedIndex].value">
			<option value="main.jsp">请选择新闻所的栏目</option>
			<%CategoryMgr categoryMgr = new CategoryMgr();
			Collection c = categoryMgr.getAll();
			Iterator iterator = c.iterator();
			while (iterator.hasNext()) {
				Category category = (Category) iterator.next();
			if (classid==category.getId()){%>
			<option value="main.jsp?classid=<%=category.getId()%>" selected><%=category.getName()%></option><%} else{%>
			<option value="main.jsp?classid=<%=category.getId()%>"><%=category.getName()%></option>
			<%}}%>
			</select>
		</form>
		</TD>
		<TD align=center bgColor=<%=tdbgcolor2%> width=30%>
		<%NewsMgr newsMgr=new NewsMgr();
		int newscount=newsMgr.getTotalByCategoryId(classid);
		%>&nbsp;&nbsp;共有<FONT COLOR="red"><%=newscount%></FONT>条新闻
		</TD>
	</TR>


<%
int perPage = 10;
int intPageCount = 0;

intPageCount = (newscount + perPage-1) / perPage;
if(page1 < 1) page1 = 1;
if(page1 > intPageCount) page1 = intPageCount;
int startPage=((page1-1)/10)*10+1;
c.removeAll(c);
						 c = newsMgr.getAllByCategory(classid);
						 iterator = c.iterator();
						int j=0;
			while (iterator.hasNext()) {
				News news = (News) iterator.next();
	if(j<(page1-1)*perPage || j>page1*perPage-1){j++;continue;}
	j++;
	%>
	<TR>
		<TD bgColor=<%=tdbgcolor4%> width=8%><%=j%></TD>
		<TD bgColor=<%=tdbgcolor4%> width=70%><A HREF="editnews.jsp?id=<%=news.getId()%>"><%=news.getTopic()%></A></TD>
		<TD bgColor=<%=tdbgcolor4%> width=22% align=center><A HREF="editnews.jsp?id=<%=news.getId()%>">编辑新闻</A>
		&nbsp;<A HREF="delnews.jsp?id=<%=news.getId()%>">删除新闻</A></TD>
	</TR>
	<%}%>
	</TBODY>
</TABLE>

<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" align=center>
	<TR>
	<TD align=middle vAlign=baseline>
	<FORM action="main.jsp?page=<%=page1%>&classid=<%=classid%>" method=GET>
	<p align='left'>
	直接跳到第<INPUT name=page size=1>页<INPUT TYPE="submit">&nbsp;每页显示<font color=red><%=perPage%></font>条新闻&nbsp;共<font color=red><%=newscount%></font>条新闻&nbsp;第<font color=red><%=startPage%></font>页&nbsp;
	共<font color=red><%=intPageCount%></font>页 </FONT></p></TD>
	</FORM>
	<TD align=middle vAlign=baseline></TD>
	<TD align=right width='50%'><p align='right'>分页:
	<%=pageShow(startPage,page1,intPageCount,classid)%>
	</p></TD>
</TR>
</TABLE>

<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" align=center>
	<TR bgColor=<%=trbgcolor2%>>
	<TD align=middle background=../img/index/botback.gif vAlign=bottom width="100%">
	<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%" align=center>
	<TR>
	<TD width=1><IMG border=0 height=17 hspace=0 src="../img/index/left.gif" width=14></TD>
    <TD align=middle width="100%"></TD>
    <TD align=right width=1><IMG border=0 height=17 hspace=0 src="../img/index/right.gif"  width=14></TD>
	</TR>
	</TABLE>
	</TD>
	</TR>
</TABLE>
<%@ include file="foot.jsp"%>

<%!
//快速跳转
 String pageShow(int startPage,int intPage,int intPageCount,int classname1){
	StringBuffer buf = new StringBuffer();
	if (startPage>10)
		buf.append("<a class=list href='main.jsp?page="+(startPage-1)+"&classid="+classname1+"' title='前十页'><FONT face=webdings>9</FONT></a>&nbsp");
	else
		buf.append("<FONT face=webdings color='#ff0000'>9</FONT></a>&nbsp");

	if(intPage>1) 
		buf.append("<a class=list href='main.jsp?page="+(intPage-1)+"&classid=" + classname1+"' title='上一页'><FONT face=webdings>7</FONT></a>&nbsp;");
	else
		buf.append("<FONT face=webdings color='#ff0000'>7</FONT></a>&nbsp;");

	int i=0;
	buf.append("[&nbsp;");
	for(i=startPage;i<=startPage+9;i++){
		if(i==intPage){
			buf.append("<font color='#ff0000'>"+i+"</font>");
			buf.append("&nbsp;");
		}else{
			buf.append("<a class=list href=main.jsp?page=" +i+ "&classid="+classname1+" title='第"+i+"页'>"+ i +"</a>&nbsp;");
		}
		if(i==intPageCount) {
			i++;
			break;
		}
	}
	buf.append("]&nbsp;");
    if(intPage!=intPageCount) 
		buf.append("<a class=list href='main.jsp?page="+(intPage+1)+"&classid=" + classname1+ "' title='下一页'><FONT face=webdings>8</FONT></a>&nbsp;");
	else
		buf.append("<FONT face=webdings color='#ff0000'>8</FONT></a>&nbsp;");
	if(i<=intPageCount) 
		buf.append("<a class=list href='main.jsp?page="+i+"&classid=" + classname1+ "' title='后十页'><FONT face=webdings >:</FONT></a>");
	else
		buf.append("<FONT face=webdings color='#ff0000'>:</FONT></a>");
	return buf.toString();	
}
%>

⌨️ 快捷键说明

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