dao层
//获取nodeindex最大值,没有则为1,否则最大值加1返回
public List<TMenu> findNodeIndex(long id){

String isSql = "select max(to_number(t.node_index)) from t_me t where t.superior_id = "+id;
return (List<TMenu>) this.queryBySql(isSql);


// if(nodeList==null){
// return "1";
// }
// return nodeList.get(0);


}actiong层 List<TMe> tMeList= cdglService.findNodeIndex(superiorId);
            System.out.println("========"+tMeList.size());
            for(int i =0;i<tMeList.size();i++){
             System.out.println((TMe)tMeList.get(i).getNodeIndex());
            
            }
            System.out.println("========"+tMeList.get(0).getNodeIndex());tMeList.get(i).getNodeIndex();
这个得不到??写的有问题么??

解决方案 »

  1.   


       List<TMe> tMeList= cdglService.findNodeIndex(superiorId);
                System.out.println("========"+tMeList.size());
    //循环以前加个判断。
    if(tMeList.size()>0){
                for(int i =0;i<tMeList.size();i++){
                    System.out.println((TMe)tMeList.get(i).getNodeIndex());
                    
                }
    }
    //要把bug尽量降到最低。。
                System.out.println("========"+tMeList.get(0).getNodeIndex());debug逐步追踪错误一次就知道哪写错了。找不到就把错误信息贴出来
      

  2.   

    先看看你的findNodeIndex是否有值
      

  3.   

    1.获得对象的返回值有误,可以修改下看看
    2.debug才是王道
      

  4.   

    先看看这(List<TMenu>) this.queryBySql(isSql);有没有值
    再看看List<TMe> tMeList= cdglService.findNodeIndex(superiorId);
    tMeList有没有值,应该很快就能找出来哪错了的。
      

  5.   

    你好像isSql语句写错了,isSql得到的是字段node_index的最大值 ,而不是list对象
      

  6.   

    DAO里findNodeIndex(long id)的返回值不是List<TMenu>么
    怎么在action中的用List<TMe> tMeList去接受值的,
    应该是类型不匹配吧