[英]Calling java server side method using jquery
I need to call java class method inside jquery , how do i do that ? 我需要在jquery里面调用java类方法,我该怎么做?
For more understanding Ex: 更多了解Ex:
Class Foo{
public static void letsCall(){
// Do something here ...
}
}
I want to call this letsCall()
Method from jquery. 我想从jquery中调用这个
letsCall()
方法。
1 approach:-
1方法: -
in jquery api, to call any backend system , in your case java, you need to do ajax call to invoke your java controller or service. 在jquery api中,要调用任何后端系统,在你的情况下java,你需要做ajax调用来调用你的java控制器或服务。
jquery ajax post call (call your java controller here) jquery ajax post call(在这里调用你的java控制器)
2nd approach:-
第二种方法: -
if you need java class to take part in your jsp formation , you can go for custom tags, in your case you can look for jsf framework which basically bind your user events to your controller. 如果你需要java类参与你的jsp形式,你可以去自定义标签,在你的情况下你可以找到jsf框架,它基本上将你的用户事件绑定到你的控制器。
other frameworks - springmvc bind your jsp attributes to its corresponding models, in this case no need to use jquery , you can achieve it through spring custom tags. 其他框架 - springmvc将你的jsp属性绑定到相应的模型,在这种情况下不需要使用jquery,你可以通过spring自定义标签实现它。
spring mvc example spring mvc的例子
spring custom tags example spring自定义标签示例
Calling a backend Java method from JavaScript/jQuery in JSP 在JSP中从JavaScript / jQuery调用后端Java方法
Calling Java inside JavaScript Function 在JavaScript函数中调用Java
There are maybe a half dozen more similarly worded questions, please google first! 可能有六个类似措辞的问题,请先谷歌吧!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.