qq_17579189
Caster_Chan
2015-11-05 03:02

在JAVA中如何获取list的值

  • hql
  • java
  • 指针

这是来源

     @Override
    public List getYxzyListByYwslidZsk(Long ywslid) {
        StringBuilder hql = new StringBuilder();
        hql.append(" from " + ZSK + "  t where t.ywslid = " + ywslid);
        List list = this.findByQuery(hql.toString());
        if (list != null && !list.isEmpty()){
            return list; }
        else{return null;}
    }

下面这个是使用页面,其实已经判断不为空了,然后取出的时候报错空指针,看了看类型是对的,不知道怎么取。


                List<TpgGzfYxzy> tpgGzfYxzyList=gzfYxzyService.getYxzyListByYwslidZsk(ywslid);
                if (tpgGzfYxzyList!=null){
                    for (TpgGzfYxzy tpgGzfYxzy:tpgGzfYxzyList){
                        System.out.println(tpgGzfYxzy.getZyxl());
                        if (tpgGzfYxzy.getZyxl()==4){
                            row.setData("fourthfyd",tpgGzfYxzy.getYxdmc());};
                        if (tpgGzfYxzy.getZyxl()==5){
                            row.setData("fifthfyd",tpgGzfYxzy.getYxdmc());};
                        if (tpgGzfYxzy.getZyxl()==6){
                            row.setData("sixthfyd",tpgGzfYxzy.getYxdmc());};
                        if (tpgGzfYxzy.getZyxl()==7){
                            row.setData("seventhfyd",tpgGzfYxzy.getYxdmc());};
                    }
                }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答