jsp页面上使用java调用js脚本
我采用的是jdk1.6的新方法实现但是在页面上无法使用//ScriptEngineManagersem=newScriptEngineManager();//Script...
我采用的是jdk1.6的新方法实现 但是在页面上无法使用
//ScriptEngineManager sem = new ScriptEngineManager();
//ScriptEngine engine = sem.getEngineByName("JavaScript");
//String script = "function helloFunction(name) { return 'Hello everybody,' + name;}";
//engine.eval(script);
//Invocable inv = (Invocable) engine;
//String res = (String) inv.invokeFunction("helloFunction", "Scripting");
//out.println("res:" + res); 展开
//ScriptEngineManager sem = new ScriptEngineManager();
//ScriptEngine engine = sem.getEngineByName("JavaScript");
//String script = "function helloFunction(name) { return 'Hello everybody,' + name;}";
//engine.eval(script);
//Invocable inv = (Invocable) engine;
//String res = (String) inv.invokeFunction("helloFunction", "Scripting");
//out.println("res:" + res); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询