我searchKey在动作类和模型驱动的bean对象中有变量.
public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> {
private String searchKey;
private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();
// ...
}
Run Code Online (Sandbox Code Playgroud)
searchKey也是一个变量PaymentResponseDTO.
我需要searchKey根据某些条件从action类和modeldriven bean 访问.拥有相同名称的变量是不好的.但上面已经开发出来了.如果我在Java文件中进行任何修改,我需要做很多很难的修改.
现在我需要访问动作类变量.我尝试以下面的方式从action类访问变量:
<s:hidden id="searchKey" name="searchKey" value="%{searchKey}"/>
Run Code Online (Sandbox Code Playgroud)
但它返回空值.
我还有下面的代码:
this.setSearchKey("somevarible");
Run Code Online (Sandbox Code Playgroud)
请告知错误发生的地方
在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>
Run Code Online (Sandbox Code Playgroud)
瓷砖xml
<definition name="paymentGateWayResponse" extends="b2cHome">
<put-attribute name="body" value="agent_b2c/b2c_paymentGateWayResponse.jsp" />
</definition>
Run Code Online (Sandbox Code Playgroud)
在b2c_paymentGatewayResponse.jsp隐藏字段中存在代码.
Dav*_*ton 11
当您的模型(在堆栈顶部)和您的操作(通常是模型下面的项目)具有相同名称的属性时,您可以使用#action值堆栈上下文变量或直接访问堆栈(坏主意)消除歧义.
<!-- Access action properties directly: -->
<s:property value="%{searchKey}" /> <!-- Model; top of stack. -->
<s:property value="%{#action.searchKey}" /> <!-- Action; accessed directly. -->
<!-- Hope the stack never changes: -->
<s:property value="%{[0].searchKey}" /> <!-- Model; top of stack. -->
<s:property value="%{[1].searchKey}" /> <!-- Action; next stack pos. -->
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5623 次 |
| 最近记录: |