Calling java server side method using jquery

后端 未结 3 407
广开言路
广开言路 2021-01-16 09:56

I need to call java class method inside jquery , how do i do that ?

For more understanding Ex:

Class Foo{
      public static void letsCall(){
               


        
相关标签:
3条回答
  • 2021-01-16 10:20

    1 approach:-

    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 ajax post call (call your java controller here)

    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.

    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.

    spring mvc example

    spring custom tags example

    spring custom tag example

    0 讨论(0)
  • 2021-01-16 10:34

    Calling a backend Java method from JavaScript/jQuery in JSP

    Calling Java inside JavaScript Function

    There are maybe a half dozen more similarly worded questions, please google first!

    0 讨论(0)
  • 2021-01-16 10:40

    Check out DWR. We use it a lot to do this kind of thing and it works well. It wraps all the ajax stuff so you don't have to worry about it.

    0 讨论(0)
提交回复
热议问题