在java中解释执行javascript命令...
时间:2010-08-19 来源:xlyyc
感觉可以包装下,做个灵活的规则框架,具体做些什么,还没有想好
public static void main(String[] args) throws IOException, ScriptException{
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName ("JavaScript");
BufferedReader cmdIn = new BufferedReader(new InputStreamReader(System.in));
System.out.println("输入 \"quit\" 退出命令行");
for(;;) {
System.out.println("请输入脚本命令:");
String cmd = cmdIn.readLine();
if(cmd.equalsIgnoreCase("quit")) break;
engine.eval(cmd);
System.out.println();
}
}
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName ("JavaScript");
BufferedReader cmdIn = new BufferedReader(new InputStreamReader(System.in));
System.out.println("输入 \"quit\" 退出命令行");
for(;;) {
System.out.println("请输入脚本命令:");
String cmd = cmdIn.readLine();
if(cmd.equalsIgnoreCase("quit")) break;
engine.eval(cmd);
System.out.println();
}
}
相关阅读 更多 +