上面的写法好象不对啊。谁用过啊,帮小弟一把,再弄不出来就要被炒拉!!!
解决方案 »
- HibernateTemplate() 使用问题
- hibernate抽象的问题···,在线等,急
- 有关struts2+jquery+json的一个细节
- 谁能写一些关于WEb Service的在各种环境下的配置及开发实例?大家来帮顶了
- 这么多工作流。用哪个好?
- mybatis xml配置参数传入
- 请教:用axis开发webservice,如何使String[]作为参数?
- 在装完J2SDK后,命令提示符出现的怪问题!
- sos:发布j2ee时(deploy)出现:please connect to a server ..
- java拆分list
- 严重的tomcat问题!紧急求助!!!
- weblogic8.1 配置 2个问题:1.如何不以war方式发布web 2.配置jsp(configure a new web app ext descriptor怎么没有这个选项?)
<%@page import="java.util.Date"%>
<jsp:useBean id="DBconn1" scope="page" class="Mysql.DBconn" />
<html>
<head>
<title></title>
<STYLE type=text/css>
TD {
FONT-SIZE: 12px
}
A {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #336699; TEXT-DECORATION: underline
}
</STYLE>
<body>
<table width="95%" align="center">
<%
int i;
int ipage=7; //也面跳鼠
int allpage; //总也shu
int pages; //当前也面
int cpage=1; //指正
int spage; String sql = "select * from 数据库表 order by id desc";
ResultSet RS = DBconn1.executeQuery(sql);
RS.next();
int allCol = RS.getInt(1);
RS.close();
allpage = (int)Math.ceil((allCol + ipage-1) / ipage);
if (request.getParameter("pages")==null) {
pages=1;
} else {
pages = new Integer(request.getParameter("pages")).intValue();
}if(pages > allpage || pages == 0){
cpage = 1;
} else {
cpage = pages;
}spage=(cpage-1)*ipage;
%>
<%
sql = "select * from 数据库表 order by ** desc limit "+spage+","+ipage+"";
RS=DBconn1.executeQuery(sql);
int cu=0;
while(RS.next()){%>
<%
int id=RS.getInt("id");
String num=RS.getString("num");
String week=RS.getString("week");
String weather=RS.getString("weather");
String content=RS.getString("content");
//date=RS.getDate("date");
%>
<tr>
<td valign="top" height="44" colspan="3">
<table width="100%" border="0" cellspacing="1" cellpadding="0" bordercolor="336699" background="1.jpg">
<tr>
<td bgcolor="336699" width="24%"><font color="ffffff"><%=num%></font> </td>
<td bgcolor="336699" width="49%"><font color="ffffff"><%=week%></font></td>
<td bgcolor="336699" width="27%"><font color="ffffff"><%=weather%></font></td>
</tr>
<tr bgcolor="ffffff">
<td bordercolor="#CCCCCC" colspan="3"><%=content%></td>
</tr>
</table>
</td>
</tr>
<%
cu++;
}
RS.close();
%>
<tr valign="top">
<td width="639" valign="middle" height="30" align="right">共 <%= cu %>条记录 共 <%= allpage %>页
<% if (cpage>1) { %>
<a href="more1.jsp?pages=<%= cpage-1 %>">上一页</a>
<% } if (cpage<allpage) { %>
<a href="more1.jsp?pages=<%= cpage+1 %>">下一页</a>
<% } %>
<% for (i=1;i<=allpage;i++) { if (i != pages) {%>
<a href="more1.jsp?pages=<%= i %>"><%= i %></a>
<% } }%>
<font color="#336699">我想去第</font> </td>
<td align="right" width="70" rowspan="2">
<form name="form1" method="post" action="more1.jsp">
<input type="text" name="pages" size="4" maxlength="4" style="background-attachment: scroll; background-color: #FFFFFF; background-repeat: repeat; font-size: 9pt; height: 18px; width: 30 px; border: 1px solid #000000; background-position: 0% 50%">
<input type="submit" name="go" value="go" style="background-attachment: scroll; background-color: #FFFFFF; background-repeat: repeat; font-size: 9pt; height: 18px; width: 20 px; border: 1px solid #000000; background-position: 0% 50%">
</form>
</td>
<td valign="middle" width="12" align="right" height="30">页</td>
</tr>
<tr valign="top">
<td height="8"></td>
<td></td>
</tr>
</table>
</body>
</html>//
SQL2000
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*"%>
<%
int pagesize=2;//每页显示记录数
int recordcount=0;//记录总数
int pagecount=0;//总页数
int pageid=1;//待显页码
Connection conn=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:jspguest","sa","sa");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
//String name=request.getParameter("name");
//String pwd=request.getParameter("pwd");
//String sql="select * from system where adminname like '%"+name+"%' and name like '%"+pwd+"%' order by user_id desc";
String sql="select * from message";
ResultSet rs=stmt.executeQuery(sql);
rs.last();
recordcount=rs.getRow();//取得总记录数
pagecount=(recordcount%pagesize==0?(recordcount/pagesize):(recordcount/pagesize)+1);//取得总页数
int count=1;
String strpage=request.getParameter("pageid");
if(strpage==null) pageid=1;
else pageid=Integer.parseInt(strpage);
if(pageid>recordcount) pageid=recordcount;
if(recordcount>0){
rs.absolute((pageid-1)*pagesize+1);}
int i=0;
//rs.previous();
rs.beforeFirst();
while(rs.next()&&count<=pagesize){
count++;
i++;
out.print(rs.getString("name"));
out.print("||");
out.print(rs.getString("title"));
out.print("<br/>");
}
out.print("共");
out.print(pagecount);
out.print("页");
out.print("共");
out.print(recordcount);
out.print("条");
out.print("第");
out.print(pageid);
out.print("页");
out.print("<br/>");
if(pageid<pagecount){
out.print("<a href=del.jsp?pageid=");
out.print(pageid+1);
out.print(">下一页</a>");}
if(pageid>1){
out.print("<a href=del.jsp?pageid=");
out.print(pageid-1);
out.print(">上一页</a>");}
out.print("<br/>");
for(int j=1;j<=pagecount;j++){
out.print("<a href=del.jsp?pageid=");
out.print(j);
out.print(">");
out.print(j);
out.print("</a>");}
stmt.close();
conn.close();
}
catch(ClassNotFoundException e){
out.println(e.getMessage());
}
catch(SQLException e) {
out.println(e.getMessage());
}
finally{
try{
if(conn != null)
conn.close();
}
catch(Exception e){}
}
%>