我有个疑问.Struts2 Modeldriven
接口如何工作.在我的应用程序中,我用于单个表单.我将setter和getter与表单名称相同.是否可以ModelDriven
使用setter和getter 放置多个对象.如果我这样放置它会如何识别?
我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
隐藏字段中存在代码.