简体   繁体   中英

How to pass parameters to a vm file (Velocity) from another vm file (velocity) through java script?

My review.vm file contain a table of records. When user click one of those records in the table ,I want to pass id and data of that record as parameters and call update.vm file from review.vm file through java script. the java script function in review.vm looks below:

  function callUpdateVm(id,data) {
    var vmcall = "update.vm";
    window.location.href = vmcall;
    }

may i know how to pass the id and date also to update.vm?

If you are using velocity tools, then your javascript can be like:

var vmcall = "update.vm?id=" + id;

and on the server side, your update.vm file can access HTTP query parameters using the ParameterTool :

#set($id = $params.id)

This being said, you must of course be careful about access rules to your update.vm URL if you aren't inside a protected area, otherwise malicious users could trigger unwanted updates.

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