| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2301 人关注过本帖
标题:JSP中显示数据库中记录时总报异常
只看楼主 加入收藏
zhang1065
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-10-2
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
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">密 &nbsp;码</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.(DefaultErrorHandler.java:92)
    org.apache.(ErrorDispatcher.java:330)
    org.apache.(JDTCompiler.java:423)
    org.apache.(Compiler.java:308)
    org.apache.(Compiler.java:286)
    org.apache.(Compiler.java:273)
    org.apache.jasper.(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 
2013-10-02 12:46
cai410579517
Rank: 3Rank: 3
来 自:宁德
等 级:论坛游侠
威 望:6
帖 子:128
专家分:179
注 册:2013-8-18
收藏
得分:20 
看看你的Dao里面是怎么写的 你取出list大小看一下是会值
2013-10-03 20:01
zhang1065
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-10-2
收藏
得分:0 
  谢谢了啊,解决了
2013-10-11 19:57
qwe885167759
Rank: 4
等 级:业余侠客
威 望:5
帖 子:148
专家分:259
注 册:2013-3-12
收藏
得分:0 
楼主怎么弄的啊

我本楚狂人,凤歌笑孔丘
2015-06-05 15:38
快速回复:JSP中显示数据库中记录时总报异常
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017491 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved