📄 index.jsp
字号:
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2006-6-20 Time: 9:29:00 To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=GB2312" language="java" %><%@ taglib uri="/WEB-INF/TagLib.tld" prefix="custTag" %><%@ page errorPage="errorPage.jsp"%><%@ page import="java.util.*"%><%@ page import="java.sql.*"%><jsp:useBean id="PageBean" class="beans.PageBean" scope="page" /><jsp:useBean id="PictureBean" class="beans.PictureBean" scope="page"/><% int currentPage=1; //当前页(第一次显示的肯定是第一页啦!~),以后的“当前页”由下面出现的页面中的pages参数传入 int allPage=-1; String sql; ArrayList rs = new ArrayList(); String pages=request.getParameter("pages");//取得页面中pages参数,此参数代表的页面的就是要显示的“当前页面” if(pages!=null) currentPage=Integer.valueOf(pages).intValue();//这是一个Integer型转int型的例子,第一次执行这个页面的时候,pages这个参数是null,currentPage=1;当再次执行这个页面的时候,参数pages将被赋值,currentPage=pages的int值 sql = "select id,name,type,pos,detail from pictures";//这样返回的结果集会采用desc降序排列,好处是,显示在前面的是最新的信息 PageBean.getResult(sql); allPage = PageBean.countMaxPage() ; //得到总页码数 rs=PageBean.getPagedRs(currentPage);//得到当前页面要显示的结果集%><html> <head><title>图片管理系统</title> <LINK href="css/css.css" type="text/css" rel="stylesheet"> </head> <body background="image/t1.jpg"> <img src=image/banner.jpg alt=""/> <table > <tr><td> <form action="login.do" method="post" type="LoginForm"> 用户登录 用户名:<input type = text name = "logname" size=8> 密码:<input type = password name = "password" size=8> <input type = submit name = "logsub" value = "登录"> <a href="register.jsp" target="_blank">注册</a> </form> </td><td> <form action="search.do" method="post" type="formbean.SearchForm" >图片检索 <input type = text name = "searchtext" size=11> <select name="pictype" ><option value="quanbu" >全部</option><option value="fengjing" >风景</option><option value="renwu" >人物</option><option value="dongwu" >动物</option> </select> <input type = submit name = "searchsub" value ="查找图片"> </form> </td></tr> </table> <br> <table align = "center" id="r" width=100% border=0 cellpadding=7 cellspacing=0><% for(int i = 0 ; i < rs.size() ; i ++){ PictureBean = (beans.PictureBean)rs.get(i) ;//得到数据库(结果集)中id编号 if(i % 3 == 0){%><tr><%}%> <td align =center > <a href="<%=PictureBean.getPosition() %>" target="_blank"><IMG src=<%=PictureBean.getPosition() %> border="0"></a><br> <font size="1"><%=PictureBean.getPictype()%></font> <br> <font size="1"><%=PictureBean.getDescription()%></font> <br> <a href="<%=PictureBean.getPosition() %>" target="_blank"><%=PictureBean.getPicname()%></a> <br></td> <% if(i % 3 == 2){%> </tr> <%}%><%}%> <tr><td height="1"></td></tr> <tr> <td colspan=4 align =center> 现在是第<%=currentPage%>页<%if(currentPage>1){%> <!--如果不在第一页,则显示出“首页”链接--> <A HREF="index.jsp?pages=<%=(currentPage-1)%>">首页</A><%} for(int i=1;i<=allPage;i++){//显示出1、2、3、4……到最后一页的链接 out.println("<a href=index.jsp?pages="+i+">"+i+"</a>"); }%><%if(currentPage<allPage){%> <!--如果不在最后一页,则显示出“末页”链接--> <A HREF="index.jsp?pages=<%=(currentPage+1)%>">末页</A><%}%></td> </tr> </table> <table align="center"><tr><td><custTag:Copyright>copyright</custTag:Copyright></td></tr></table> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -