我正在使用 groovy/nashorn 作为 java 引擎,但无法插入字符串。
jdk.nashorn.api.scripting.NashornScriptEngine scriptEngine =(NashornScriptEngine) factory.getEngineByName("nashorn");
ScriptContext context = scriptEngine.getContext();
Bindings bindings = context.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put("x","Guest");
engine.eval("Hello, ${x}",context);
但我得到了 javax.script.ScriptException。是否支持字符串插值?谢谢