Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
问题 I used the following code with the Rhino JavaScript engine in Java: @Test public void testRhino() throws ScriptException { final ScriptEngineManager factory = new ScriptEngineManager(); final ScriptEngine engine = factory.getEngineByName("rhino"); final String raw = "I am the raw value injected"; final ScriptContext ctx = new SimpleScriptContext(); ctx.setAttribute("raw", raw, ScriptContext.ENGINE_SCOPE); String script = "var result = 'I am a result';"; script += "java.lang.System.out.println