Topic: 各位大虾帮帮忙 |
Print this page |
1.各位大虾帮帮忙 | Copy to clipboard |
Posted by: J2EE1982 Posted on: 2005-08-18 17:57 <%@ page language = "java" contentType = "text/html;charset=gb2312" errorPage="error.jsp"%> <%@ page import = "java.sql.*" %> <%@ page import = "com.Mysql" %> <% Mysql mysql = new Mysql(); int intPage; int currentPage = 1; int PageNumbers = 10; if(request.getParameter("page")!=null && request.getParameter("page")!="") intPage = Integer.parseInt(request.getParameter("page")); else intPage = 1; int totalRecord = 0; ResultSet counters = mysql.executeQuery("select count as cnt from stsNews"); if(counters.next()) { totalRecord = counters.getInt("cnt"); } %> <html> <head><title>新闻发布系统1.0版</title> <LINK href="css/sts.css" rel=stylesheet type=text/css> </head> <body> <div align="center" style="width: 901; height: 21"> <%@ include file="inc/top.jsp" %> <br> <table border = 0 width="505" cellspacing="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111"> <tr bgcolor="#00ff00"><td width="505" colspan=2><img src="pic\qq.gif">新闻标题</td></tr> <% if(session.getValue("name")==null || session.getValue("name")=="") { %> <% String strSQL = "select id,title from stsNews order by id desc"; ResultSet rs = mysql.executeQuery(strSQL); int i=0; while(rs.next()) { if(i >= (intPage-1)*PageNumbers && i < intPage*PageNumbers) { String id = rs.getString("id"); String title = rs.getString("title"); out.print("<tr bgcolor = \"#00dc45\"><td width=300 valign=\"top\"><img src=\"pic\\gb.gif\"><a href=\"view.jsp?id="+id+"\">"+ title +"</a></td><td></td></tr>"); } i++; } %> </table> </div> <% rs.close(); } else { %> <% String strSQL = "select id,title from stsNews order by id desc"; ResultSet rs = mysql.executeQuery(strSQL); int i=0; while(rs.next()) { if(i >= (intPage-1)*PageNumbers && i < intPage*PageNumbers) { String id = rs.getString("id"); String title = rs.getString("title"); out.print("<tr bgcolor = \"#00dc45\"><td valign=\"top\" width=\"90%\"><img src=\"pic\\gb.gif\"><a href=\"view.jsp?id="+id+"\">"+ title +"</a></td><td width=\"10%\"><a href=\"delete.jsp?id="+id+"\">删除</a></td></tr>"); } i++; } %> </table> <% rs.close(); } %> <br> <div align="center" >新闻总数:<%= totalRecord %> 当前页数:<%=currentPage%> 每页显示<%=PageNumbers%>条 共<%=(totalRecord+PageNumbers)/PageNumbers%>页 <a href="index.jsp?page=1">首页</a> <% if(intPage>1 && intPage<((totalRecord+PageNumbers)/PageNumbers)) { out.print("<a href='index.jsp?page=" + (intPage-1) + "'>上一页 </a>"); out.print("<a href='index.jsp?page=" + (intPage+1) +"'>下一页 </a>"); out.print("<a href='index.jsp?page=" + ((totalRecord+PageNumbers)/PageNumbers) + "'>最后一页</a>"); } if(intPage ==((totalRecord+PageNumbers)/PageNumbers)) out.print("<a href='index.jsp?page=" + (intPage-1) + "'>上一页 </a>"); if(intPage == 1) { out.print("<a href='index.jsp?page=" + (intPage+1) +"'>下一页 </a>"); out.print("<a href='index.jsp?page=" + ((totalRecord+PageNumbers)/PageNumbers) + "'>最后一页</a>"); } %> </div> <% counters.close(); %> <div align="center"><a href="manager.jsp" >进入管理</a> <a href="manager.jsp">发布文章</a> <a href="admin.jsp">登录</a><br> <%@ include file="inc/bottom.jsp" %></div> </body> </html> 一个新闻发布系统的主页面,Mysql.java是相关的 mysql jdbc操作. 运行出错: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.index_jsp._jspService(index_jsp.java:72) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. |
2.Re:各位大虾帮帮忙 [Re: J2EE1982] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-08-19 02:17 不知您的Mysql 是如何定义的? 既然是“java.lang.NullPointerException”,建议你单步执行,或是一句句的通过输出调试信息来判断是哪个对象为null吧。 对你这样简单的问问题,却不多做介绍,觉得不妥,少了些诚意。 |
3.Re:各位大虾帮帮忙 [Re: J2EE1982] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-08-19 02:24 http://www.cjsdn.net/post/view?bid=51&id=153300 重复发帖,扣分,希望您能在希望获取的同时先付出些精力! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |