<%@ page countentType="text/html;charset=GB2312"%>Invalid attribute, countentType至少countentType错了,应该是contentType,先改了这个,你要看错误信息呀,否则以后怎么调试程序?
解决方案 »
- java 线程执行顺序
- 是学J2EE好呢,还是C++
- 高分:无法得到消息队列消息,在线等!!!!
- webservice问题高手请进,给点思想谢谢!
- java编程的一些错误,很奇怪
- tomcat5下配置运行servlet,出现找不到网页错误,在线等!!!!
- 学习struts
- 有哪位朋友能看明白下面的错误信息的?(关键字:linux,weblogic,ejb,bea-010054)
- javamail接收邮件疑难问题(望java望高手给于解答,高分相送)
- 100分求大神指点如何用JAVA检测出untrusted ssl cetificate
- 求助!!
- JSP编辑器打不开!(Eclipse3.0.1&Lomboz3.1.0&Tomcat5.5.4)急啊!在线等!
我的一个详细的jsp分页程序!(oracle+jsp+apache)
一 前提
希望最新的纪录在开头给你的表建立查询:
表:mytable
查询:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列号create sequence mytable_sequence 来自动增加你的纪录id号 二 源程序
<%String sConn="你的连接"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"你的用户名","密码");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs=stmt.executeQuery("select * from mytable_view");
String sqlcount="select count(*) from mytable_view";
ResultSet rscount=stmtcount.executeQuery(sqlcount); int pageSize=你的每页显示纪录数;
int rowCount=0; //总的记录数
while (rscount
int pageCount; //总的页数
int currPage; //当前页数
String strPage;
strPage=request.getParameter("page");
if (strPage==null){
currPage=1;
}
else{
currPage=Integer.parseInt(strPage);
if (currPage<1) currPage=1;
}
pageCount=(rowCount+pageSize-1)/pageSize;
if (currPage>pageCount) currPage=pageCount; int thepage=(currPage-1)*pageSize;
int n=0;
rs.absolute(thepage+1);
while (n<(pageSize)&&!rs
%>
<%rs.close();
rscount.close();
stmt.close();
stmtcount.close();
conn.close();
%> //下面是 第几页等
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)">
第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首页</a><%}%>
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一页</a><%}%>
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一页</a><%}%>
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=<%=pageCount%>&condition=<%=condition%>&type=<%=type%>">尾页</a><%}%>
跳到<input type="text" name="page" size="4" style="font-size:9px">页
<input type="submit" name="submit" size="4" value="GO" style="font-size:9px">
</form>
countentType ->contentType
class="Counter.Counter"
<jsp:useBean id="people" class="Counter.Counter" scope="application">
</jsp:useBean>去除
<%@ page import="Counter"%>就可以了。還有就是要在
(counter.class)放在tomcat的classes文件夹里 新建的Counter文件夹中。
大小寫注意。
把Counter.class放到你的WEB-INF\classes\Counter目录下
把<jsp:useBean id="people" class="Counter" scope="application">
</jsp:useBean>改为 <jsp:useBean id="people" class="Counter.Counter" scope="application">
</jsp:useBean>