gpt4 book ai didi

java - struts 2 - 将参数从一个页面传递到另一个页面

转载 作者:行者123 更新时间:2023-12-01 05:21:21 24 4
gpt4 key购买 nike

需要使用 Struts 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>

我得到的错误是:

消息:没有为操作模型定义结果。HfddispAction 和结果大量测试在这里我可以说它是什么

文件:文件:/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”时,我收到上述错误我正在尝试的只是将 AD REF NO 4150 传递给操作并在另一页中显示说明

最佳答案

使用 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 标签 value 属性,因为它默认解析提供的名称。

使用变量的多个属性可以让事情变得更清晰:

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

然后当你需要它时:

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

此外,您还应该能够将当前 url 中的所有参数包含到新 url 中,方法是:

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

有关更多信息,请参阅标签引用 http://struts.apache.org/2.3.1.2/docs/tag-reference.html

关于java - struts 2 - 将参数从一个页面传递到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10364894/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com