2016年9月18日 | Leave a comment 问题: 如下代码中 ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("js"); engine.eval("a.f1('aaaa')"); 123 ScriptEngineManager manager = new ScriptEngineManager();ScriptEngine engine = manager.getEngineByName("js");engine.eval("a.f1('aaaa')"); f1 是Java Object a方法 解决: ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("js"); engin.put("a",a); engine.eval("a.f1('aaaa')"); 1234 ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("js"); engin.put("a",a);engine.eval("a.f1('aaaa')"); 参考: