Java GWT中的JSNI方法

Java GWT中的JSNI方法,java,javascript,gwt,jsni,Java,Javascript,Gwt,Jsni,在我遇到这种情况之前,它是有效的: JS侧: jsMethod : function(){...} public static native void javaMethod(JavaScriptObject obj) /*-{ var test = null; test = ... ; test.jsMethod(); }-*/; GWT Java端: jsMethod : function(){...} public static native void

在我遇到这种情况之前,它是有效的:

JS侧:

jsMethod : function(){...}
public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;
    test.jsMethod();    
}-*/;
GWT Java端:

jsMethod : function(){...}
public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;
    test.jsMethod();    
}-*/;
问题是当我尝试这样做的时候

JS侧

jsMethod : function(a, b){... return string}
String a = 'yes'
String b = 'no'

public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b);   
}-*/;
GWT Java端

jsMethod : function(a, b){... return string}
String a = 'yes'
String b = 'no'

public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b);   
}-*/;

我将把参数从GWT传递到JS,然后返回一个字符串,但我不知道如何实现它。谢谢。

就像Java一样。返回一个字符串

public static native String javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b); 
    return testString;  
}-*/;

您可以向本机JavaMethod添加参数

public static native String javaMethod(JavaScriptObject obj, String a, String b)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b);
    return testString;
}-*/;

好的,但我不知道如何传递参数,是否需要:“[instance expr.]@class name::method name(param signature)(arguments)”?