美文网首页
SpEL调用静态方法

SpEL调用静态方法

作者: snapshot | 来源:发表于2019-08-01 13:27 被阅读0次

···

@Test
public void test1(){
    ExpressionParser parser = new SpelExpressionParser();

    String spelStr="T(java.lang.Math).random()*10";
    Double aDouble = parser.parseExpression(spelStr).getValue(Double.class);
    System.out.println(aDouble);  //6.218185851768058

    String spelStr1="T(org.apache.commons.lang3.math.NumberUtils).isNumber('123')";
    Boolean aBoolean = parser.parseExpression(spelStr1).getValue(Boolean.class);
    System.out.println(aBoolean);  //true
}

···

相关文章

网友评论

      本文标题:SpEL调用静态方法

      本文链接:https://www.haomeiwen.com/subject/squqdctx.html