Your question is rather vague. But the typical scenario in Struts2 is: you have an action with some properties which follow the Java bean conventions ( say, a 'myval' property is accesible via getMyval() and setMyval() public methods).
When invoking the action, the default configuration (with default interceptor stack) maps the http parameters calling the setter. Ej, if you call http:/..../myAction.action?myval=xx Struts2 will instance your action and call the method setMyval("xx") (if your property is not a string, struts2 will try to convert it).
After the action execution, when the results are displayed in the view (say,a JSP page), you might write <s:property value='myval' /> and Struts2 will invoke the method getMyval() of your action.
This is the most basic and typical workflow, but I'm simplyfing, everything is much more general and customizable.
发布评论
评论(1)
你的问题比较模糊。但 Struts2 中的典型场景是:您有一个带有一些遵循 Java bean 约定的属性的操作(例如,可以通过 getMyval() 和 setMyval() 访问“myval”属性) /code> 公共方法)。
调用操作时,默认配置(使用默认拦截器堆栈)映射调用 setter 的 http 参数。 Ej,如果您调用
http:/..../myAction.action?myval=xx
Struts2 将实例化您的操作并调用方法setMyval("xx")
(如果你的属性不是字符串,struts2会尝试转换它)。操作执行后,当结果显示在视图(例如 JSP 页面)中时,您可以编写
并且 Struts2 将调用该方法您的操作的getMyval()
。这是最基本和典型的工作流程,但我很简单,一切都更加通用和可定制。
Your question is rather vague. But the typical scenario in Struts2 is: you have an action with some properties which follow the Java bean conventions ( say, a 'myval' property is accesible via
getMyval()
andsetMyval()
public methods).When invoking the action, the default configuration (with default interceptor stack) maps the http parameters calling the setter. Ej, if you call
http:/..../myAction.action?myval=xx
Struts2 will instance your action and call the methodsetMyval("xx")
(if your property is not a string, struts2 will try to convert it).After the action execution, when the results are displayed in the view (say,a JSP page), you might write
<s:property value='myval' />
and Struts2 will invoke the methodgetMyval()
of your action.This is the most basic and typical workflow, but I'm simplyfing, everything is much more general and customizable.