将多个动作映射到同一个类 struts 2.3 是最佳实践吗 [英] Is it best practice to map multiple actions to the same class struts 2.3

查看:27
本文介绍了将多个动作映射到同一个类 struts 2.3 是最佳实践吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用选项(添加、删除、修改、打印)在 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,是对你必须执行的每个操作使用一个 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
|

等等...

其他人扩展的每个 Action 都会将 protected 属性/方法共享给子项.

Every Action extended by others will share protected attributes / methods to the children.

看看这个:在 Struts 2 中绑定后更改参数

我的 2 美分.

这篇关于将多个动作映射到同一个类 struts 2.3 是最佳实践吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆