JSP中显示数据库中记录时总报异常
<%@ page language="java" pageEncoding="GB18030"%><%@ page import="com.play.test.bean.*" %>
<%@ page import="com.play.test.dao.*" %>
<%@ page import="com.play.test.daoImpl.*" %>
<%@ page import="java.util.*" %>
<%
request.setCharacterEncoding("GB18030");
UserDao userDaoService = new UserDaoService();
List<User> users = userDaoService.getUsers();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>用户列表</title>
</head>
<body>
<form action="showusers.jsp" name="form" method="post">
<input type="hidden" name="action" value="register" />
<table align="center" border="2">
<tr>
<td colspan="4" align="center">用户列表</td>
</tr>
<tr>
<td align="center">用户ID</td>
<td align="center">用户名</td>
<td align="center">密 码</td>
<td align="center">用户<br/>操作</td>
</tr>
<%
for(Iterator<User> it= users.iterator();it.hasNext();){
User user = it.next();
%>
<tr>
<td align="center"><%=user.getId() %></td>
<td align="center"><%=user.getUsername() %></td>
<td align="center"><%=user.getPassword() %></td>
<td align="center">
<a href="deleteuser.jsp">删除用户</a>
</td>
</tr>
<%
}
%>
<tr>
<td colspan="4" align="center">
<a href="index.jsp">返回</a>
</td>
</tr>
</table>
</form>
</body>
</html>
注意:在类中已经实现了jdbc对数据库的连接以及查询方法的实现,但是总是报异常如下:
HTTP Status 500 -
--------------------------------------------------------------------------------
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: 9 in the jsp file: /showusers.jsp
The method getUsers() is undefined for the type UserDao
6: <%
7: request.setCharacterEncoding("GB18030");
8: UserDao userDaoService = new UserDaoService();
9: List<User> users = userDaoService.getUsers();
10: %>
11:
12: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.14
求高人指点
搜索更多相关主题的帖子:
PUBLIC import 数据库 title java
----------------解决方案--------------------------------------------------------
看看你的Dao里面是怎么写的 你取出list大小看一下是会值
----------------解决方案--------------------------------------------------------
谢谢了啊,解决了
----------------解决方案--------------------------------------------------------