简体   繁体   English

如何通过Java脚本将参数从另一个vm文件(速度)传递到vm文件(速度)?

[英]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. 我的review.vm文件包含一个记录表。 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. 当用户单击表中的那些记录之一时,我想将该记录的ID和数据作为参数传递,并通过java脚本从review.vm文件调用update.vm文件。 the java script function in review.vm looks below: review.vm中的Java脚本函数如下所示:

  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? 我可以知道如何将ID和日期也传递给update.vm吗?

If you are using velocity tools, then your javascript can be like: 如果您使用的是力度工具,那么您的javascript可能类似于:

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

and on the server side, your update.vm file can access HTTP query parameters using the ParameterTool : 在服务器端,您的update.vm文件可以使用ParameterTool访问HTTP查询参数:

#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. 话虽这么说,但如果您不在保护区内,那么您当然必须谨慎对待update.vm URL的访问规则,否则恶意用户可能会触发不需要的更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM