当前位置: 首页 > 工具软件 > Express Map > 使用案例 >

QLExpress对map判断

锺离浩慨
2023-12-01

1.导入依赖

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>QLExpress</artifactId>
    <version>3.2.0</version>
</dependency>

2.使用,这里我只做简单的使用

public static void test() throws Exception {
    ExpressRunner runner = new ExpressRunner();
    IExpressContext<String,Object> expressContext = new DefaultContext<>();
    //需要判断的map
    expressContext.put("date", "2021-01-19");
    expressContext.put("result", "成功");
    expressContext.put("ip", "192.168.179.135");
    //判断语句
    String expression ="date < '2021-01-20' and result == '成功' and ip == '192.168.179.135'";
    //执行
    Object execute = runner.execute(expression, expressContext, null, true, false);

    System.out.println(execute);
}
 类似资料: