[英]struts 2 - Passing parameters from one page to another
Help needed passing parameters with Struts 2. 使用Struts 2帮助所需的传递参数。
<action name="Hfddisp1" class="model.HfddispAction" method="fetch_addesc">
<result >model.HfddispAction?ad_ref_no=${ad_ref_no}</result>
</action>
My jsp is 我的jsp是
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
</head>
<body>
<h1> Iterator tag example 12</h1>
<h3>Iterator with IteratorStatus 12</h3>
<table>
<tr class="even">
<td><b>Ad_ref_no</b></td>
<td><b>Ad_title</b></td>
</tr>
<s:iterator value="hftbList" status="hftbListStatus">
<tr>
<s:if test="#hftbListStatus.even == true">
<td style="background: #CCCCCC"><s:property value="ad_ref_no" /> </td>
<td style="background: #CCCCCC"><s:property value="ad_title" /> </td>
<td style="background: #CCCCCC">
<a href="<s:url action="Hfddisp1"/>">click here-1 </a>
</td>
</s:if>
<s:else>
<td>
<s:property value="ad_ref_no" />
</td>
<td>
<s:property value="ad_title" />
</td>
<td >
<a href="<s:url action="Hfddisp2"/>
<s:param name="ad_ref_no" value="% {ad_ref_no}" /> ">
click here2
</a>
</td>
</s:else>
</tr>
</s:iterator>
</table>
Error i am getting is: 我得到的错误是:
Messages: No result defined for action model.HfddispAction and result huge volume of test goes here i can say what is it 消息:没有为动作模型定义结果。HfddispAction和结果大量测试在这里我可以说是什么
File: file:/E:/Web_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Gshax/WEB-INF/classes/struts.xml 文件:文件:/ E:/Web_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Gshax/WEB-INF/classes/struts.xml
I am getting the data in the iterator but can not show it in another page. 我在迭代器中获取数据,但无法在其他页面中显示。
<--------qry is executed2hftb_add_master[ad_ref_no=huge volume of test goes here i can say what is it,email_address=null]
<--------qry is executed2huge volume of test goes here i can say what is it
description successfully queried:1 huge volume of test goes here i can say what is it
Apr 26, 2012 12:07:04 PM org.apache.struts2.dispatcher.Dispatcher serviceAction
SEVERE: Could not find action or result
From the first page the output i get is 从第一页我得到的输出是
Ad_ref_no Ad_title
12123120 i am the king but not sing click here-1
213421123 new test1 click here-2
4150 Ad_title ........11:32:08 click here-1
4152 Ad_title ........11:32:09 click here-2
4153 Ad_title ........11:32:10 click here-1
when I click the click here -1 i am getting the above error ALL I AM TRYING IS TO PASS THE THE AD REF NO 4150 TO THE ACTION AND DISPLAY DESCRIPTION IN ANOTHER PAGE 当我单击“单击此处-1”时,出现上述错误,我想通过的是将广告参考号4150传递给另一页中的操作和显示说明
Using the Struts2 url and param tags... 使用Struts2 url和param标签...
Currently you have this: <s:url action="Hfddisp2"/><s:param name="ad_ref_no" value="% {ad_ref_no}" />
Note that the param tag is not nested inside the url tag. 当前,您具有: <s:url action="Hfddisp2"/><s:param name="ad_ref_no" value="% {ad_ref_no}" />
请注意,param标签未嵌套在url标签内。
You could write this: <s:url action="Hfddisp2"><s:param name="ad_ref_no"/></s:url>
您可以这样写: <s:url action="Hfddisp2"><s:param name="ad_ref_no"/></s:url>
Note in the above that the param tags value attribute is omitted because it defaults to resolving the name provided. 在上面请注意,由于默认情况下解析参数名称,因此省略了param标签value属性。
With several attributes using a variable can make things clearer: 通过使用几个属性可以使变量更清楚:
<s:url var="myurl" action="Hfddisp2">
<s:param name="ad_ref_no"/>
</s:url>
Then later where ever you need it: 然后在以后您需要的地方:
<s:property value="#myurl"/>
Also you should be able to include all the parameters in the current url into the new url by saying: 您还应该能够说出当前URL中的所有参数到新URL中:
<s:url action="Hfddisp2" includeParams="get"/>
For more information always consult the tag reference http://struts.apache.org/2.3.1.2/docs/tag-reference.html 有关更多信息,请始终查阅标签参考http://struts.apache.org/2.3.1.2/docs/tag-reference.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.