当前台将一个null空值传输到后台,将会变成一个String的”null”,而后台通过接口传入到另一个系统后台后将会在进行一次封装(传输的值都未经处理),另一个系统要判断传过来是否为空:StringUtils.isEmpty(值)和StringUtils.isNotEmpty(值)进行比较返回都为false,然后通过测试发现必须要用equals比较才能正确的返回true.
本人进过的测试:
System.err.println("customerIdStr:" + customerIdStr);
System.out.println(customerIdStr == null);
System.out.println(customerIdStr == "");
System.out.println(customerIdStr == "null");
System.out.println(customerIdStr == " ");
System.out.println(customerIdStr == "null ");
System.out.println(customerIdStr.equals(null));
System.out.println(customerIdStr.equals(""));
System.out.println(customerIdStr.equals("null"));只有本结果返回true
System.out.println(customerIdStr.equals(" "));
System.out.println(customerIdStr.equals("null "));
时间: 2024-11-07 22:30:49