如何使用OGNL调用操作方法 [英] How to call an action method using OGNL
本文介绍了如何使用OGNL调用操作方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用OGNL调用操作方法?
How to call an action method using OGNL?
helloAction.java
helloAction.java
public String getQuote()
{
return "Don't think, just do";
}
success.jsp
success.jsp
<b>quote() :</b> <s:property value="quote()"/> <br>
struts.xml
struts.xml
<action name="greet" class="com.struts2.helloAction" >
<interceptor-ref name="firewallStack"></interceptor-ref>
<result name="SUCCESS">/WEB-INF/resources/success.jsp</result>
<result name="input">/WEB-INF/resources/success.jsp</result>
</action>
未调用此 quote()
方法。我正在使用xwork-2.0.1.jar和ognl-2.6.11.jar。
This quote()
method is not called. I am using xwork-2.0.1.jar and ognl-2.6.11.jar.
推荐答案
不调用此quote()方法。我使用的是xwork-2.0.1.jar和ognl-2.6.11.jar。
This quote() method is not called. I am using xwork-2.0.1.jar and ognl-2.6.11.jar.
你没有那种方法你的行动如果您创建它:
You don't have that method in your action. If you create it:
public String quote() {
并使用普通的OGNL方法调用语法:
and use normal OGNL method call syntax:
<s:property value="%{quote()}" />
然后将根据需要调用它。
then it will be called as desired.
这篇关于如何使用OGNL调用操作方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文