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是最佳实践吗
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
