天过无痕 2019-11-01 15:02 采纳率: 0%
浏览 778
已采纳

ssh框架,接口实现类调用service方法报空指针异常

            //**实现类代码**
            String tname = saleName;
            String id =  goodIds;
            //调用service层方法,传入两个参数。报空指针
            int count = tpcCombinationSaleService.querySaleindexName(tname, id);


            //**service代码**
            public int querySaleindexName(String indexName,String id)
            throws com.sinovatech.common.exception.AppException;


            //**impl代码**
            @Override
    public int querySaleindexName(String indexName,String id) throws com.sinovatech.common.exception.AppException {
        indexName = indexName.trim();
        String sql="";
        if(!id.equals("")){
            sql = "select * from DATA_RRYX.T_PC_COMBINATION_SALE Z where Z.NAME='" + indexName + "' and Z.id <> '"+id+"' and Z.is_delete = 'N'";
        }else{
            sql = "select * from DATA_RRYX.T_PC_COMBINATION_SALE Z where Z.NAME='" + indexName + "'  and Z.is_delete = 'N'";
        }
        return tpcCombinationSaleDAO.getRecordCountBySQL(sql);

以上为代码,现在我运行测试类正常传参进去后,debug的时候走到调用service方法,没有走方法内部,就直接跳转到Thread类,的dispatchUncaughtException方法,然后就报了空指针异常,请问大佬们可能的原因是在哪里?

  • 写回答

2条回答 默认 最新

  • zhshchilss 2019-11-01 16:49
    关注

    1.确保tpcCombinationSaleService不是null,打断点看一下
    2.确保两个参数是否为null
    3.如果都没问题,断点打到这一行 indexName = indexName.trim(); 然后一步一步debug看哪一行有问题
    4.报的错有没有说是哪一行

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法