代码主要实现  从数据库 搜索用户  显示到页面   从 UserManager 的 findUser() 进入后就空指针了  查不出原因汗

解决方案 »

  1.   

    如果你确定你的SQL语句可以查询到结果。那么把方法改成这样试试try { 
    conn = DB.getConn(); 
    stmt = conn.createStatement(); 
    rs = stmt.executeQuery(sql); 
    while(rs.next()) { 
    User user = new User(); 
    user.setUserid(rs.getString("user_id")); 
    user.setUsername(rs.getString("user_name")); 
    user.setPassword(rs.getString("password")); 
    user.setTel(rs.getString("contact_tel")); 
    //user.setEmail(rs.getString("email")); 
    user.setCreatedate(rs.getDate("create_date")); 
    userlist.add(user); 
    } catch (SQLException e) { 
    e.printStackTrace(); 
      

  2.   

    类名第一个字母要大写,还有第一次见有人userManager.getInstance().findUser(); 这样直接掉查询方法的,连get,set方法都不写,还不知道userManager这个类你配置文件里面定义了没有
      

  3.   

    get 和 set 有  只是我删除了一部分代码 
     
     问题似乎 是userDao 没有初始化 
      

  4.   

    private static userDao  userdao = new userDaoImplement(); 
      

  5.   

    研究近一周,居然是SPRING注入的问题看我的代码在SPRING配置文件中,首先需要注入PaginationServImpl的DAO
    <bean id="Seradd" class="com.hents.page.PaginationServImpl"  >
    <property name="pagingDao">
    <ref bean="SpecMDAO" />
    </property>
    </bean>
    然后要在ACTION中使用PaginationServImpl的接口,需要如下的定义关联。把Seradd注入到ACTION
    <bean id= "ttt" class= "com.hents.action.ProductAction" scope="prototype" >
    <property name="pagingServ" ref="Seradd" />
    </bean> 最后,STRUTS调用TTT