【发布时间】:2012-07-09 14:20:06
【问题描述】:
我有 searchKey 作为动作类和模型驱动 bean 对象中的变量。
public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> {
private String searchKey;
private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();
// ...
}
searchKey也是PaymentResponseDTO中的一个变量。
我需要根据某些条件从动作类和模型驱动 bean 访问searchKey。具有相同名称的变量是不好的。但是上面的已经开发好了。如果我在 Java 文件中做任何修改,我需要做很多困难的修改。
现在我需要访问动作类变量。我尝试通过以下方式从动作类访问变量:
<s:hidden id="searchKey" name="searchKey" value="%{searchKey}"/>
但它返回的是空值。
我也有以下代码:
this.setSearchKey("somevarible");
请指出问题出在哪里
struts.xml
<action name="atomResponse" class="com.PaymentGateWayAction" method="atomPaymentResponse">
<result name="success" type="tiles">paymentGateWayResponse</result>
<result name="failure" type="tiles">paymentGateWayResponseError</result>
</action>
瓷砖 xml
<definition name="paymentGateWayResponse" extends="b2cHome">
<put-attribute name="body" value="agent_b2c/b2c_paymentGateWayResponse.jsp" />
</definition>
在b2c_paymentGatewayResponse.jsp 中存在隐藏域代码。
【问题讨论】:
-
我似乎不明白你的问题。你有
searchKey作为你的动作类和模型驱动bean 中的变量吗?你有searchKey变量的 getter 和 setter。 -
@UchennaNwanyanwu.. 我有 searchKey 作为动作变量和模型驱动 bean,我有 searchKey 的 setter 和 getter
-
你没有回答第一个问题。你有
searchKey作为你的动作类和你的模型驱动bean中的变量吗? -
@UchennaNwanyanwu... 是的。我在两者中都有 searchKey 作为变量..
-
模型驱动中的 searchKey 优先,因为您的 Action 类实现了
ModelDriven。