吉祥三宝之矿大版 interceptor和ognlvaluestack
Mar 23

在Webwork中,我们应该仔细规划Action的职责:

对于关联性很高的几种职责,可以放入一个Action中,然后让每个method去执行一种任务,以提高Action的利用率,同时模块划分更加合理,这方面的讨论请看可以处理多个请求的Action
对于一个复杂的结果页面,我们也完全不必由一个Action来负责生成,也可以划分为多个Action,每个Action承担单一的职责,然后在结果页面进行组装,这样对于那些职责单一的Action来说,完全可能被复用到其他页面中去,并且对于结果页面来说,也不必完全自己生成,可以由几个Action 组装而来;

在JSP页面中组装Action方式如下:

"helloAction" name="hello" namespace="/" executeResult="true" />

或者使用Freemarker

<@ww.action id="helloAction" name="hello" namespace="/" executeResult="true" />

executeResult指明是否将action对应的结果页面生成的HTML内容放在当前的标签位置上,一般而言,会使用true,这样就可以方便的由多个Action的执行结果页面来组装一个复杂的页面了。

如果仅仅需要Action执行的逻辑功能,或者需要Action执行完毕携带的数据,但是需要自己完全组装页面,也可以设为false,引用方式如下:

"helloAction" name="hello" namespace="/" executeResult="false" />
"#helloAction.username"/>

或者使用Freemarker

<@ww.action id="helloAction" name="hello" namespace="/" executeResult="false" />
${helloAction.username}


Like others
Trackback:10

Leave a Reply

Identifying Code