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是最佳实践吗
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
