Is this possible for use javascript to call a java method?

后端 未结 4 2055
太阳男子
太阳男子 2021-01-02 18:18

The java have a script manager that allow java calling javascript, like this:

import javax.script.*;
public class ExecuteScript {
 public static void main(St         


        
4条回答
  •  旧时难觅i
    2021-01-02 19:15

    I'm not sure what script manager you are using but with Rhino you can do things like

    var date = new java.util.Date();
    print(date);
    

    So with your example you should be able to call it like a static method:

    ExecuteScript.sayHi();
    

提交回复
热议问题