最好的做法是将多个操作映射到同一个struts 2.3中 [英] Is it best practice to map multiple actions to the same class struts 2.3
问题描述
我正在考虑映射多个操作(将多个操作映射到相同的类struts 2.3)到同一个类( ContactManager
)。
我想知道是否正确或是否需要为每个动作写入单独的动作?
一个 imho 是使用一个Action来执行每个动作,每个动作都会扩展其最后一个分支的父操作,如:
BaseAction
|
| ---------- BaseReportAction
| | ----- ExcelReportAction
| | ----- PDFReportAction
| | ----- CSVReportAction
|
|
| ---------- BaseCRUDAction
| | ----- CreateAction
| | ----- ReadAction
| | ----- UpdateAction
| | ----- DeleteAction
|
|
| ---------- BaseAJAXAction
| | ----- ReadSessionCountdownAction
| | ----- CheckNewMailsAction
|
等...
每个动作由他人扩展将向孩子们分享 protected
属性/方法。
看看这个: struts2,绑定后更改参数
我的2美分。
I am developing contact manager in struts with options(add,delete,modify,print).
I am thinking to map multiple actions(map multiple actions to the same class struts 2.3) to the same class(ContactManager
).
I want to know whether it is correct or whether there is need to write separate action for each action?
One good way to go, imho , is to use one Action for every action you have to perform, each one extending its last-forked parent Actions, like:
BaseAction
|
|----------BaseReportAction
| |----- ExcelReportAction
| |----- PDFReportAction
| |----- CSVReportAction
|
|
|----------BaseCRUDAction
| |----- CreateAction
| |----- ReadAction
| |----- UpdateAction
| |----- DeleteAction
|
|
|----------BaseAJAXAction
| |----- ReadSessionCountdownAction
| |----- CheckNewMailsAction
|
etc...
Every Action extended by others will share protected
attributes / methods to the children.
Take a look at this: struts2, changing parameters after bind
My 2 cents.
这篇关于最好的做法是将多个操作映射到同一个struts 2.3中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!