而是我自己另起的这个e:\jsp 文件夹下
jsp可以运行
但bean我放在e:\jsp\web-inf\classes\DBconn\
下,但是jsp找不到bean!
怎么回事?
是不是要做相关配置?
附上有关地方的代码:
DBconn.java
package DBconn;
import java.sql.*;
public class DBconn {
String DBDriver = "org.gjt.mm.mysql.Driver";
String ConnStr = "jdbc:mysql://xxx.xxx.xxx.xxx/uuu?user=www&password=xxx&useUnicode=true&characterEncoding=GBK";
Connection conn = null;
ResultSet rs = null;
public DBconn(){
try {
Class.forName(DBDriver);
//加载数据库驱动程序
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("DBconn (): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql){
rs = null;
try {
conn = DriverManager.getConnection(ConnStr);
//与DBMS建立连接
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}
test.jsp
<body>
<p><b>客户信息调查</b></p>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="DBconn1" scope="page" class="DBconn.DBconn" />
<%
ResultSet RS = DBconn1.executeQuery("select menu_name,menu_icon from tbl_Menu order by menu_order");
while (RS.next()) {
out.print("<LI>" + RS.getString("menu_name") + "</LI>");
out.print("<LI>" + RS.getString("menu_ic") + "</LI>");
}
RS.close();
%>
</body>
望给位救命
5 个解决方案
#1
报错页面:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: DBconn/DBconn
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: DBconn/DBconn
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: DBconn/DBconn
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: DBconn/DBconn
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
#2
在Tomcat的server.xml文件中的</Host>前加一句呢:
<Context path="/jsp" docBase="E:\jsp" reloadable="true"/>
<Context path="/jsp" docBase="E:\jsp" reloadable="true"/>
#3
注意是WEB-INF,不是web-inf
#4
我的目录室:WEB-INF\classes\..所以不存在以上问题
#5
<%@ page language="java" import="java.sql.*" %>
此处加引包DBconn
<%@ page language="java" import="java.sql.*,DBconn.*" %>
此处加引包DBconn
<%@ page language="java" import="java.sql.*,DBconn.*" %>
#1
报错页面:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: DBconn/DBconn
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: DBconn/DBconn
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: DBconn/DBconn
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: DBconn/DBconn
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
java.lang.Class.getConstructor0(Class.java:1922)
java.lang.Class.newInstance0(Class.java:278)
java.lang.Class.newInstance(Class.java:261)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
#2
在Tomcat的server.xml文件中的</Host>前加一句呢:
<Context path="/jsp" docBase="E:\jsp" reloadable="true"/>
<Context path="/jsp" docBase="E:\jsp" reloadable="true"/>
#3
注意是WEB-INF,不是web-inf
#4
我的目录室:WEB-INF\classes\..所以不存在以上问题
#5
<%@ page language="java" import="java.sql.*" %>
此处加引包DBconn
<%@ page language="java" import="java.sql.*,DBconn.*" %>
此处加引包DBconn
<%@ page language="java" import="java.sql.*,DBconn.*" %>