<%@ page contentType="text/html; charset=gbk"%>
<%@page import="smartmt.db.DataSourceFactory"%>
<%@page import="java.util.ArrayList"%>
<%@page import="smartmt.model.Address"%>
<%@page import="smartmt.db.AddressDao"%>
<%@page import="smartmt.model.AddressGroup"%>
<%@page import="smartmt.model.Bill"%>
<%@page import="java.util.HashMap"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<html>
<head>
<title>.</title>
<meta content="text/html; charset=GBK" http-equiv="Content-Type">
<style type="text/css" media="all">
       @import url("../css/displayTag/maven-base.css");
       @import url("../css/displayTag/maven-theme.css");
       @import url("../css/displayTag/site.css");
       @import url("../css/displayTag/screen.css");
     </style>
     <link rel="stylesheet" href="../css/misc2.css" type="text/css">
     <link rel="stylesheet" href="../css/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/thickbox.js"></script>
</head>
<%
     String start = request.getParameter("start");
         String name = request.getParameter("name");
Long userId = (Long)session.getAttribute("userId");
String phone = request.getParameter("phone");
if(userId == null) {
%><script>top.window.location.href='../index.htm'</script><%
return;
}
AddressDao aDao = new AddressDao(DataSourceFactory.getDataSource());
String groupId = request.getParameter("groupId");
long lGroupId = -1;
if(groupId != null) {
lGroupId = Long.parseLong(groupId);
}
AddressDao add=new AddressDao(DataSourceFactory.getDataSource());
ArrayList<HashMap<String, String>> aList = add.getMoList(userId, start, phone,  name);


 %>
<body bgcolor="#efefef">
<form id="addrForm" method="get" action="manual.jsp">
        <% request.setAttribute( "aList", aList ); %>
        <display:table name="aList" pagesize="20" decorator="smartmt.display.AddressDecorator" id="dis">
          <display:column property="checkBox" title="选中"/>
  <display:column property="name" title="姓名" />
  <display:column property="groupName" title="分组"/>
  <display:column property="phone" title="手机号码"/>
  <display:column property="company" title="公司"/>
  <display:column property="address" title="地址"/>
        </display:table>
        </form>
            <form method="get" action="b_all.jsp">
<input type="submit" value="返回"/>
</form>
</body>
</html>org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 44 in the jsp file: /AddressBook/b_nameall.jsp
The method getMoList(Long, String, String, String) is undefined for the type AddressDao
41: 
42:  %>
43:  <%AddressDao add=new AddressDao(DataSourceFactory.getDataSource());
44:  ArrayList<HashMap<String, String>> aList = add.getMoList(userId, start, phone,  name);
45: 
46:   %>
47:  <body bgcolor="#efefef">
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:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

解决方案 »

  1.   

    这种错误只能在jsp页面上打断点调试
      

  2.   

    ArrayList<HashMap<String, String>> aList = add.getMoList(userId, start, phone, name);代码问题,把变量,返回结果都打印出来看看
      

  3.   

    ArrayList<HashMap<String, String>> aList = add.getMoList(userId, start, phone, name);
    he method getMoList(Long, String, String, String) is undefined for the type AddressDao重新编译 部署 试试 ,不行debug看看
      

  4.   

    The method getMoList(Long, String, String, String) is undefined for the type AddressDao
    这不写的挺明白的吗,看方法名有没有写错还有就是看看传的参数类型是不是和AddressDao里面定义的一样。
      

  5.   

    DAO的代码
    public ArrayList<HashMap<String, String>> getMoList(long userId, String start, String phone, String name) {
    String condition = "";
    if(userId != -1) {
    String userSql = "select id from plat_address_book with(nolock) where parentPath like '%S" + userId + "E%'";
    List userTbl = dbexec.queryForList(userSql);
    Iterator userIt = userTbl.iterator();
    String keyUserId = "(" + userId;
    while(userIt.hasNext()) {
    Map rec = (Map)userIt.next();
     keyUserId += "," + (Long)rec.get("id");
    }
    keyUserId += ")";
    condition += " and user_id in" + keyUserId;
    }
    if(name != null && !"".equals(name)){
    // 根据Name来查询
    long keyUserId = -1;
    String userSql = String.format("select id from plat_address_book with(nolock) where name='%s'", name);
    List userTbl = dbexec.queryForList(userSql);
    Iterator userIt = userTbl.iterator();
    if(userIt.hasNext()) {
    Map rec = (Map)userIt.next();
    keyUserId = (Long)rec.get("id");
    }
    if(keyUserId != -1) {
    condition += String.format(" and user_id=%d", keyUserId);
    }
    }
    if(phone != null && !"".equals(phone)) {
    condition += " and phone='" + phone + "'";
    }
    ArrayList<HashMap<String, String>> moList = new ArrayList<HashMap<String, String>>();
    String sql = String.format("select * from plat_address_book with(nolock) " +
    "where create_time between '%s' and '%s' %s order by create_time desc", start, condition);
    System.out.println("sql:" + sql);
    List tbl = dbexec.queryForList(sql);
    Iterator it = tbl.iterator();
    try {
    while(it.hasNext()) {
    Map rec = (Map)it.next();
    HashMap<String, String> hashRec = new HashMap<String,String>();
    hashRec.put("name", (String)rec.get("name"));
    hashRec.put("phone", (String)rec.get("phone"));
    hashRec.put("job", (String)rec.get("job"));
    hashRec.put("address", (String)rec.get("address"));
    hashRec.put("userId", "" + (Long)rec.get("user_id"));
    moList.add(hashRec);
    }
    } catch(Exception e) {
    System.out.println("检索上行失败!" + e.getMessage());
    return null;
    }
    return moList;
      

  6.   

    如果是tomcat 先在tomcat下找到编译后的jsp 然后报错行号 把那行代码贴出来,。你的问题其实很简单。。
      

  7.   


    41:  ArrayList<HashMap<String, String>> aList1= aDao.getMoList(userId, start, phone,  name);这行报错。
      

  8.   

    Long userId = (Long)session.getAttribute("userId");DAO的代码
    public ArrayList<HashMap<String, String>> getMoList(long userId, String start, String phone, String name)要么你也可以弄一个
    public ArrayList<HashMap<String, String>> getMoList(Long userId, String start, String phone, String name)
      

  9.   

    在其他的地方调过这个DAO的这个方法吗?如果其他地方没错的话就诡异了,如果其他地方没调过的话,你看是不是DAO实例化错了,还是在构造里面有什么其他处理影响了实例化的对象。
      

  10.   


    我在这个页面调用一个这么简单的DAO  都会有错 怎么回事? ArrayList<Address> aList1=aDao.adreesName(name);
    @SuppressWarnings("unchecked")
    public ArrayList<Address> adreesName(String name)
    {
    ArrayList<Address> aList=new ArrayList<Address>();
    String sql = "select * from plat_address_book with(nolock) where  name" + name;
    List tbl = dbexec.queryForList(sql);
    Iterator it = tbl.iterator();
    while(it.hasNext()) {
    Address add = new Address();
    Map rec = (Map)it.next();
    add.setName((String)rec.get("name"));
    add.setPhone((String)rec.get("phone"));
    add.setJob((String)rec.get("job"));
       add.setCompany( (String)rec.get("company"));
    add.setAddress((String)rec.get("address"));
    aList.add(add);
    }
    return aList;
      

  11.   

    The method getMoList(Long, String, String, String) is undefined for the type AddressDao
    引得包对么。
      

  12.   

    select * from plat_address_book with(nolock) where name" + name;sql有with???检查下sql是否有问题
      

  13.   

    Map rec = (Map)it.next();你把结果转换为Map??不对吧
      

  14.   

    Map rec = (Map)it.next();
    这个能转吗?没见过。
      

  15.   

    The method getMoList(Long, String, String, String) is undefined for the type AddressDao不是写得很清楚了吗?这个方法不存在 我估计你方法的第一参数设为int
      

  16.   

    The method getMoList(Long, String, String, String) is undefined for the type AddressDao而你dao里面写的是这个
    public ArrayList<HashMap<String, String>> getMoList(long userId, String start, String phone, String name) 
    参数类型不匹配 你传进去的是个Long对象
      

  17.   

    这个方法是你新添加的吗?在tomcat里的class文件是不是最新的
      

  18.   

    An error occurred at line: 44 in the jsp file: /AddressBook/b_nameall.jsp
    The method getMoList(Long, String, String, String) is undefined for the type AddressDao
    41: 
    42: %>
    43: <%AddressDao add=new AddressDao(DataSourceFactory.getDataSource());
    44: ArrayList<HashMap<String, String>> aList = add.getMoList(userId, start, phone, name);到  AddressDao.java 中的 getMoList 方法中设置个断点调试一下