Is it best practice to map multiple actions to the same class struts 2.3(将多个动作映射到同一个类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 ,就是为你必须做的每一个动作使用一个动作执行,每个都扩展其最后一个分叉的父操作,例如:
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是最佳实践吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将多个动作映射到同一个类struts 2.3是最佳实践吗


基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01