简体   繁体   中英

How to pass javascript array to java applet method?

I have applet that contains method:

public void send(byte[] arr) {
   ... //some code
}

But when I call this method from JS I get the error:

java.lang.IllegalArgumentException: No method found matching name send and arguments [sun.plugin2.main.client.MessagePassingJSObject]

If I set send method argument to String and then pass string argument from JS to applet, then it`s ok. No warnings.

How to pass array from JS to java method correctly?

http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html contains some examples.

Javascript does not have a byte type, at least not in the browser. Try passing in an the arguments as int[] or String[] and casting/converting in your applet to a byte array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM