I'm using Struts2. I need to pass a parameter from my jsp to the action. The parameter is different depending on which link we want to see although the action is the same. I don't know how to do this... My code without passing parameters i开发者_如何学JAVAs this:
<% if (usuario.getComputeEngines().size() > 0) {
int contador = 1;
Long idCE;
for (int i=0; i < usuario.getComputeEngines().size(); i++){
idCE = usuario.getComputeEngines().get(i).getIdComputeEngine();
%>
<td width="50%" align="center" valign="top">
<br clear=all>
<s:a href="%{CE}"><img src="images/casa<%out.println(contador); %>
.jpg" border="0"></s:a>
<br><%=i%>
<br>
</td>
The parameter i need to pass to the action is i. It's just a number. How could I do this? Thanks in advanced!
<s:url ="CE" action="action">
<s:param name="name" value="value"/>
</s:url>
This is only part of it, and it needs an id. You need to then associate the url with the anchor tag:
<s:url id="myUrl" action="action">
<s:param name="name" value="value"/>
</s:url>
<s:a href="%{myUrl}"><img src="images/casa<%out.println(contador); %>
.jpg" border="0"></s:a>
You can put as many tags in there as you want. I've also noticed that the form...
<s:param name="name" value="value"/>
...sometimes does not work and I tend to use:
<s:param name="name">value</s:param>
you can pass a parameter in
<s:url ="CE" action="action">
<s:param name="name" value="value"/>
</s:url>
精彩评论