包:
import com.googlecode.aviator.AviatorEvaluator;
使用:
参数中,单双引号可以叠加使用:
双引号引用变量, 双引号套用单引号表示字符串.
String yourname = “aviator”; Map<String, Object> env = new HashMap<String, Object>(); env.put("yourname", yourname); String result = (String) AviatorEvaluator.execute(" 'hello ' + yourname ", env); System.out.println(result);
结果:
hello aviator
三元表达式:
AviatorEvaluator.execute("3>0? 'yes':'no'");
https://www.iteye.com/news/16695-aviator