为什么 javabean使用的时候说 package doesn't exist

tiamoming 2010-10-01 08:38:31
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 8 in the jsp file: /untitled.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\testWeb_Project\org\apache\jsp\untitled_jsp.java:48: package reg does not exist
reg.dbconn query = null;
^



An error occurred at line: 8 in the jsp file: /untitled.jsp

Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\testWeb_Project\org\apache\jsp\untitled_jsp.java:50: package reg does not exist
query = (reg.dbconn) pageContext.getAttribute("query", PageContext.PAGE_SCOPE);
^



An error occurred at line: 8 in the jsp file: /untitled.jsp

Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\testWeb_Project\org\apache\jsp\untitled_jsp.java:52: package reg does not exist
query = new reg.dbconn();
^
3 errors


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
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)



以下是简单的测试代码,因为其他页面太复杂,但使用的是同样的使用javabean的方法,
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<jsp:useBean id="query" scope="page" class="reg.dbconn" />
<body>
<%
query.setConnection("root","root");
ResultSet rs = query.getResult("select * from topic");
String str = null;
while(rs.next()){
str = rs.getString(2);
}
query.destroy();
%>
<div>
<%= str%>
</div>
</body>
</html>

因为白天 一直在移动文件夹,所以才造成了重大的问题
...全文
70 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
funfun5433 2010-10-01
把java代码贴出来 看下上面的包名对不
回复
jeky_zhang2013 2010-10-01
检查下web.xml中servlet的配置路径,多试下
回复
closewbq 2010-10-01
class="reg.dbconn"
包名只是reg吗?class是包名.类名
回复
Apeipo 2010-10-01
class="reg.dbconn" ->问题.
回复
yangfeiblog 2010-10-01
像这种问题,只要你的bean写对了的,那就仔细检查路径,只要路径对了,一般不会提示啥不存在
而且你页面里哪儿来的那么多java代码??为啥不用标签??数据库操作都写到页面你觉得这样好吗??以后怎么维护?
回复
yangfeiblog 2010-10-01
这个很明显是路径的问题噻
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2010-10-01 08:38
社区公告
暂无公告