gpt4 book ai didi

java - Spring 表达式语言检查字符串是否包含在字符串列表中

转载 作者:行者123 更新时间:2023-11-30 06:16:51 25 4
gpt4 key购买 nike

我有以下 SPEL 测试代码:

public void test(){
ExpressionParser parser = new SpelExpressionParser();

String input = "ADITYA";
List<String> coreTeam = Arrays.asList("ASHISH","ADITYA","SUMANT","SHASHIKANT","HATIM");

System.out.println(coreTeam.toString());

StandardEvaluationContext coreTeamContext = new StandardEvaluationContext(coreTeam);
coreTeamContext.setVariable("CORE_TEAM",coreTeam);
coreTeamContext.setVariable("CHEK_TEAM",input);

Expression exp40 = parser.parseExpression("#CORE_TEAM.contains(#CHECK_TEAM)");
Boolean s = exp40.getValue(coreTeamContext,Boolean.class);

}

其输出始终为 false。

我错过了什么?

最佳答案

这是拼写错误,您输入了 CHECK_TEAM iso“CHEK_TEAM”。下面的代码会给你真实的。ExpressionParser 解析器 = new SpelExpressionParser();

 String input = "ADITYA";
List<String> coreTeam = Arrays.asList("ASHISH","ADITYA","SUMANT","SHASHIKANT","HATIM");

System.out.println(coreTeam.toString());

StandardEvaluationContext coreTeamContext = new StandardEvaluationContext(coreTeam);
coreTeamContext.setVariable("CORE_TEAM",coreTeam);
coreTeamContext.setVariable("CHEK_TEAM",input);

Expression exp40 = parser.parseExpression("#CORE_TEAM.contains(#CHEK_TEAM)");
Boolean s = exp40.getValue(coreTeamContext,Boolean.class);

关于java - Spring 表达式语言检查字符串是否包含在字符串列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49002697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com