12345678_0001
当它在服务器端时,请使用Web服务-可能是带有JSON的RESTful。创建一个Web服务(例如,使用Tomcat)从JavaScript调用其URL(例如,使用JQuery或dojo)当Java代码位于applet中时,您可以使用JavaScript桥。Java和JavaScript编程语言之间的桥梁(非正式地称为LiveConnect)是在Java插件中实现的。现在,在所有浏览器中都可以使用以前专用于Mozilla的LiveConnect功能,例如调用静态Java方法,实例化新Java对象和从JavaScript引用第三方程序包的功能。以下是文档中的示例。看看methodReturningString。Java代码:public class MethodInvocation extends Applet { public void noArgMethod() { ... } public void someMethod(String arg) { ... } public void someMethod(int arg) { ... } public int methodReturningInt() { return 5; } public String methodReturningString() { return "Hello"; } public OtherClass methodReturningObject() { return new OtherClass(); }}public class OtherClass { public void anotherMethod();}网页和JavaScript代码: