我使用spring表达式语言有以下代码:
StandardEvaluationContext stdContext = new StandardEvaluationContext();
stdContext.setVariable("emp", filterInputData);
ExpressionParser parser = new SpelExpressionParser();
parser.parseExpression("#emp.?[name.toLowerCase().contains('Hari')]").getValue(stdContext);
Run Code Online (Sandbox Code Playgroud)
其中emp是bean的名称.这里的名称可以为null,并且在调用时name.toLowerCase()我得到一个nullpointer异常.如何处理此方案中的空值?我只需要调用toLowercase()非空值.
java中是否有任何选项可以创建具有 true 和 false 的枚举,如下所示,
public enum options {
true,
false,
both
}
Run Code Online (Sandbox Code Playgroud)
现在,当我使用 true 和 false 时出现意外的令牌错误。谢谢
问候哈鲁