1.现象
- 当我们发起ajax请求时,如果后台得到的结果是null,那么ajax的回调函数不会走success而是走error回调函数
2.原因
- 当使用@ResponseBody返回json数据时,如果返回的值是null,那么,该值是不返回的,因为null值无法被转为json格式,而且其前端回调函数走的也是error
3.解决办法
String merName = reportDayService.selectMerNameByMerNo(merNo) == null ? "": reportDayService.selectMerNameByMerNo(merNo);