最好的做法是将多个操作映射到同一个struts 2.3中 [英] Is it best practice to map multiple actions to the same class struts 2.3

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

问题描述



我正在考虑映射多个操作(将多个操作映射到相同的类struts 2.3)到同一个类( ContactManager )。



我想知道是否正确或是否需要为每个动作写入单独的动作?

解决方案

一个 imho 是使用一个Action来执行每个动作,每个动作都会扩展其最后一个分支的父操作,如:

  BaseAction 
|
| ---------- BaseReportAction
| | ----- ExcelReportAction
| | ----- PDFReportAction
| | ----- CSVReportAction
|
|
| ---------- BaseCRUDAction
| | ----- CreateAction
| | ----- ReadAction
| | ----- UpdateAction
| | ----- DeleteAction
|
|
| ---------- BaseAJAXAction
| | ----- ReadSessionCountdownAction
| | ----- CheckNewMailsAction
|

等...



每个动作由他人扩展将向孩子们分享 protected 属性/方法。



看看这个: struts2,绑定后更改参数



我的2美分。


I am developing contact manager in struts with options(add,delete,modify,print).

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?

解决方案

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
|

etc...

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

Take a look at this: struts2, changing parameters after bind

My 2 cents.

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

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