支柱2 - 传递参数从一个网页到另一个

问题描述:

帮助需要传递参数和Struts 2支柱2 - 传递参数从一个网页到另一个

<action name="Hfddisp1" class="model.HfddispAction" method="fetch_addesc"> 
    <result >model.HfddispAction?ad_ref_no=${ad_ref_no}</result> 
</action> 

我的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> 

错误我得到的是:

消息:没有为动作模型定义的结果.HdddispAction和结果巨大的测试量在这里我可以说它是什么

文件:file:/ E:/Web_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Gshax/WEB-INF/classes/struts.xml

我得到迭代器中的数据,但无法在其他页面中显示。

<--------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 

从第一页的输出我得到的是

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 

当我单击单击此处-1我收到上述错误 ALL我想是传递广告REF NO 4150到另一个页面

+1

您可以通过此表达式查看的网址”>'? – 2012-04-29 17:33:28

使用Struts2的URL和param标签的行动,并显示描述...

目前你有这样的:<s:url action="Hfddisp2"/><s:param name="ad_ref_no" value="% {ad_ref_no}" />注该param标记不嵌套在url标记内。在上述<s:url action="Hfddisp2"><s:param name="ad_ref_no"/></s:url>

注意,param标签值的属性被忽略,因为它默认为解决提供的名称:

你可以写这个。

与使用变量可以让事情更清晰一些属性:

<s:url var="myurl" action="Hfddisp2"> 
    <s:param name="ad_ref_no"/> 
</s:url> 

再后来在任何你需要它:

<s:property value="#myurl"/> 

你也应该能够包含在当前所有的参数网址转换为新的网址:

<s:url action="Hfddisp2" includeParams="get"/> 

欲了解更多信息始终con sult the tag reference http://struts.apache.org/2.3.1.2/docs/tag-reference.html