Mybatis 判断表达式除坑
Mybatis 判断表达式经常有各种坑,比如数值的判断,空值的判断坑等,可以通过如下代码测试一下是否符合预期
import org.apache.ibatis.ognl.Ognl;
import org.apache.ibatis.ognl.OgnlException;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class Ongl {
@Test
public void testOngl() throws OgnlException {
Map<String,Integer> reqMap = new HashMap<>();
reqMap.put("status", -1);
Map<String,Map<String,Integer>> param = new HashMap<>();
param.put("request", reqMap);
System.out.println(Ognl.getValue(Ognl.parseExpression("request.status != null and request.status != -1"), param));
}
}