简体   繁体   English

通过单击鼠标将变量值传递到Java中的servlet

[英]pass variable value by clicking mouse to the servlet in java

I have one java server page in which values are returning from database and using bean concept and on jsp page i have used c:for each loop so i am able to get the answer so i have made one particular column as link using like this 我有一个Java服务器页面,其中值从数据库返回并使用bean概念,在jsp页面上,我使用c:for每个循环,所以我能够得到答案,所以我使用这样的方法将一个特定的列作为链接

<td><a href = retrieve_image>${item.getIid()}</a></td>   

this code is working what i want when i click mouse on this id then this id value should pass into that servlet retrieve_image, so i can perform my task so anyone please tell me is this possible? 当我在该ID上单击鼠标时,此代码正在运行我想要的东西,然后此ID值应传递到该Servlet的retrieve_image中,因此我可以执行我的任务,所以请任何人告诉我这可能吗?

Simple you could pass the value inside your <a> like this as query string, 很简单,您可以像这样将<a>内部的值作为查询字符串传递,

<td><a href = "retrieve_image?Id=${item.getIid()}">${item.getIid()}</a></td> 

Get the value from the Id in your servlet . 从servlet中的Id获取值。 you will get the value for current iteration inside the for-each loop as you print ${item.getIid()} 在打印${item.getIid()}您将在for-each循环中获得当前迭代的值。

Hope this helps !! 希望这可以帮助 !!

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

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