相关疑难解决方法(0)

Struts2 ModelDriven接口如何工作

我有个疑问.Struts2 Modeldriven接口如何工作.在我的应用程序中,我用于单个表单.我将setter和getter与表单名称相同.是否可以ModelDriven使用setter和getter 放置多个对象.如果我这样放置它会如何识别?

model-driven struts2

9
推荐指数
1
解决办法
1万
查看次数

在JSP中访问操作实例变量和模型驱动的bean变量值

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隐藏字段中存在代码.

struts2 ognl

4
推荐指数
1
解决办法
5623
查看次数

标签 统计

struts2 ×2

model-driven ×1

ognl ×1