Tôi có đoạn mã sau sử dụng lò xo ngôn ngữ biểu hiện:Xử lý giá trị null trong mùa xuân biểu hiện ngôn ngữ
StandardEvaluationContext stdContext = new StandardEvaluationContext();
stdContext.setVariable("emp", filterInputData);
ExpressionParser parser = new SpelExpressionParser();
parser.parseExpression("#emp.?[name.toLowerCase().contains('Hari')]").getValue(stdContext);
nơi emp là tên của hạt cà phê. Ở đây tên có thể là null và khi gọi name.toLowerCase()
Tôi nhận được một ngoại lệ nullpointer. Làm thế nào để xử lý các giá trị null trong kịch bản này? Tôi cần gọi số toLowercase()
chỉ với các giá trị không null.
'toLowerCase(). Chứa ('Hari') 'luôn là' FALSE' – OrangeDog