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

Struts2 在JSP中访问操作实例变量和模型驱动的bean变量值,struts2,ognl,Struts2,Ognl,我将searchKey作为action类和模型驱动bean对象中的变量 public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> { private String searchKey; private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();

我将
searchKey
作为action类和模型驱动bean对象中的变量

public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> {
    private String searchKey;
    private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO();
    // ...
}
但它返回的是空值

我还有以下代码:

this.setSearchKey("somevarible");
请指出哪里出了问题

struts.xml


付款网关响应
paymentGateWayResponseError
平铺xml


b2c\u paymentGatewayResponse.jsp
中,隐藏的字段代码存在。

当您的模型(位于堆栈顶部)和操作(通常是模型下方的项)具有相同名称的属性时,您可以使用
\action
值堆栈上下文变量或直接访问堆栈来消除歧义(坏主意)



我似乎不明白你的问题。你的action类和模型驱动bean中是否都有
searchKey
作为变量。你有
searchKey
变量的getter和setter。@UchennaNwanyanwu..我有searchKey作为action中的变量和模型驱动bean,我有searchKey的setter和getter我没有回答第一个问题。您的action类和模型驱动bean中是否有
searchKey
作为变量。@UchennaNwanyanwu…是的。我在这两者中都有searchKey作为变量。.模型驱动中的searchKey优先,因为您的action类实现了
ModelDriven
。谢谢您的回复。我已经收到您的回复d多次遇到这个问题,但最终在action类中重命名了属性。我建议在
Struts2
文档中提供该属性。@UchennaNwanyanwu我在S2 OGNL页面上做了一个简短的说明,但它暂时不会更新。如果我想在h2 dir属性中添加此值,怎么可能?例如。
this.setSearchKey("somevarible");