如何将参数值从jquery函数传递到struts2 url标签 [英] how to pass parameter value from a jquery function to struts2 url tag

查看:81
本文介绍了如何将参数值从jquery函数传递到struts2 url标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从jquery函数传递参数. 一切都很好,但是唯一的问题是传递参数值rowObject.themeScreenshot

i am trying to pass parameter from a jquery function. Everything is fine but only problem is passing the parameter value rowObject.themeScreenshot

 <script type="text/javascript">
   function formatLink(cellvalue, options, rowObject)
     {    
        var para=rowObject.themeScreenshot; //here value is coming fine 
        alert("Json object value-"+para);  //correctly i am geting the value of para.
        return "<a style='cursor:pointer;' onClick='javascript:openDialog("+cellvalue+")'><img src='<s:url action='ImageAction' namespace='/myimage/secure'><s:param name='imageId'>"+para+"</s:param></s:url>'></a>";
     //this is returning url with empty imagId  output in url:-http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId=  
   }

我想要的是:-

http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId=anyvalue

但是现在我得到的输出是:

http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId="+para+" 变量名称作为参数值传递.为什么?

http://localhost:8080/visionbooks/myimage/secure/ImageAction?imageId="+para+" variable name is passing as prameter value.Why?

请帮助我解决这个问题.

Please help me to solve this problem.

推荐答案

Struts 2 tags在第 render 页的时间进行评估,该时间远远早于脚本运行的时间.

Struts 2 tags are evaluated at page render time, which is far before your script runs.

如果您查看页面的源代码,您将看到这些标记已转换为常规html元素.因此,不会评估para javascript变量.

If you check the source code of the page you will see those tags have been converted to regular html elements. So it the para javascript variable would not be evaluated.

您可以尝试将返回行更新为

You can try to update the return line to

return "<a style='cursor:pointer;' onClick='javascript:openDialog("+cellvalue+")'><img src='<s:url action='ImageAction' namespace='/myimage/secure'></s:url>" + "?imageId="+para+ "'></a>";

这篇关于如何将参数值从jquery函数传递到struts2 url标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆