简体   繁体   中英

How to invoke java method from javascript of .vm file

I want to call java method with parameter form .vm file can you please give me a simple example for it.

mail.vm

<HTML>
<head>
  <script >
    function functionUpdate(val){
    alert(val);
    alert(getElementById(val).value);  
    //now here i wanna call java method from my java class with 'val' as parameter                          
    }
  </script>
</head>

<BODY>
<br>
<span style='font-family:Arial; font-size:13px;'>
  <p>Dear User,
  <p>Please Rate the Module with your experience
  <form  name="ratings" >
  <input id="$rate" name="$rate" value="1" type="submit" onclick="functionUpdate('$rate');">
</span>
</BODY>
</HTML>

thank you

Javascript run at client side and java code runs at server side.

so you cannot directly call java method in javascript function.

although you can use ajax call using get or post method to call some servlet, and do call your methods.

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