JiaHe's Blog

读万卷书,行万里路

脚本

ScriptUtil.eval 执行Javascript脚本,参数为脚本字符串。

栗子:

ScriptUtil.eval("print('Script test!');");

ScriptUtil.compile 编译脚本,返回一个CompiledScript对象

栗子:

CompiledScript script = ScriptUtil.compile("print('Script test!');");
try {
script.eval();
} catch (ScriptException e) {
throw new ScriptRuntimeException(e);
}