小弟初学jsp,调试出现500错误。。请大家给支招呀··
我的配置是 myeclipse 5.5 jdk1.6 Tomcat 5.0 有人说tomcat不支持jdk1.6 不知道是不是。。
源码:
<%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html; charset=gb2312" %> <jsp:directive.page import="my.blog.BLL.RunSql" /><jsp:directive.page import="my.blog.info.Info" /><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>Mpl博客程序 - Mpl小组</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css">--> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <font color="#333" id="title_div_style">CStrings博客系统</font> <% String sql = "select title,[type],createDate,author,click,comment from nr_table"; //list集合保存信息 List list = new ArrayList(); RunSql rs = new RunSql(); list = rs.RunSelect(sql); //开始输出数据 for (int i = 0; i < list.size(); i++) { Info blogInfo = (Info) list.get(i); %> <table width="100%" border="0" cellspacing="2" id="wz_div_style"> <tr> <td colspan="4" id="bt_div_style"> <%=blogInfo.title%> </td> </tr> <tr> <td id="lie_div_style"> 类别: <%=blogInfo.type%> </td> <td> 发布时间: <%=blogInfo.createDate%> </td> <td> 评论: <%=blogInfo.comment%> </td> <td> 浏览: <%=blogInfo.click%> </td> </tr> </table> <% } %> </body></html>
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)
root cause
java.lang.NoSuchMethodError: my.blog.BLL.RunSql.RunSelect(Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;
org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
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.
--------------------------------------------
Apache Tomcat/5.0.28
[解决办法]
RunSelect 这个方法 在java文件中如何写的?
[解决办法]
重新编译一下整个项目。
检查RunSql这个类中是不是有RunSelect()方法,错误日志的字面意思是RunSql类中没有RunSelect()方法。
[解决办法]
把RunSql顯示一下
[解决办法]
你关闭一下 数据库连接试下...
在finally中关闭ResultSet、Statement、Connection对象所产生的对象
[解决办法]
<jsp:directive.page import="my.blog.BLL.RunSql" />
<jsp:directive.page import="my.blog.info.Info" />
这样子正确引入了吗,为什么不用<%@ page inport="" %>
[解决办法]