mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
1f554b7759
commit
f8c3b8c109
@ -17,6 +17,9 @@ public class JexlEngine implements ExpressionEngine {
|
||||
|
||||
private final org.apache.commons.jexl3.JexlEngine engine;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public JexlEngine(){
|
||||
engine = (new JexlBuilder()).cache(512).strict(true).silent(false).create();
|
||||
}
|
||||
|
@ -19,16 +19,15 @@ public class RhinoEngine implements ExpressionEngine {
|
||||
|
||||
@Override
|
||||
public Object eval(final String expression, final Map<String, Object> context) {
|
||||
final Context ctx = Context.enter();
|
||||
final Scriptable scope = ctx.initStandardObjects();
|
||||
if (MapUtil.isNotEmpty(context)) {
|
||||
context.forEach((key, value)->{
|
||||
// 将java对象转为js对象后放置于JS的作用域中
|
||||
ScriptableObject.putProperty(scope, key, Context.javaToJS(value, scope));
|
||||
});
|
||||
}
|
||||
final Object result = ctx.evaluateString(scope, expression, "rhino.js", 1, null);
|
||||
Context.exit();
|
||||
return result;
|
||||
try(final Context ctx = Context.enter()){
|
||||
final Scriptable scope = ctx.initStandardObjects();
|
||||
if (MapUtil.isNotEmpty(context)) {
|
||||
context.forEach((key, value)->{
|
||||
// 将java对象转为js对象后放置于JS的作用域中
|
||||
ScriptableObject.putProperty(scope, key, Context.javaToJS(value, scope));
|
||||
});
|
||||
}
|
||||
return ctx.evaluateString(scope, expression, "rhino.js", 1, null);
|
||||
} // auto close
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user