问题描述
我正在用选项(添加、删除、修改、打印)在 struts 中开发联系人管理器.
I am developing contact manager in struts with options(add,delete,modify,print).
我正在考虑将多个动作(将多个动作映射到同一个类 struts 2.3)映射到同一个类(ContactManager).
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?
推荐答案
一个好方法,imho ,就是为你必须做的每一个动作使用一个动作执行,每个都扩展其最后一个分叉的父操作,例如:
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 |
等等……
其他人扩展的每个Action都会将protected属性/方法分享给孩子.
Every Action extended by others will share protected attributes / methods to the children.
看看这个:在Struts 2中绑定后更改参数一个>
我的 2 美分.