在Action中调用方法 [英] Invoking methods in Action

查看:262
本文介绍了在Action中调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究基于Struts web的应用程序,其中我创建了一个包含多个方法的动作类。我根据我希望应用程序执行的任务类型调用这些方法。有人可以告诉我是否应该使用这种方法吗?

I'm working on Struts web based application where I have created an action class with multiple methods in it. I invoke these methods based on the kind of task I want the application to perform. Could someone please tell me if I should use this technique to do so?

我应该继续调用像我这样的方法,还是应该为每个不同的动作创建单独的动作类我想表演?

Should I continue invoking the methods like I am or should I create separate action classes for every different action I want to perform?

推荐答案

一个动作类可以有很多动作,很多方法,但是你应该只将一个方法映射到动作。

One action class can have many actions, many methods, but you should map only one method to the action.

另请注意:在最近的版本中,DMI(动态方法调用)默认情况下处于关闭状态,将来可能无法使用。

Also note: in the recent releases DMI (Dynamic Method Invocation) is turned off by default and might not work in the future.

目前还不清楚你如何调用方法,一些拦截器仍在进行方法过滤,你可以限制某些方法。但是在同一个动作类中映射不同的动作没有限制。并且在视图层上调用任何动作类的方法没有限制。

It's unclear how do you invoke methods, some interceptors still evolve a method filtering, where you can restrict some methods. But there's no restriction to map different actions in the same action class. And there's no restriction to invoke any action class' method on the view layer.

此外,映射到方法的操作可以直接或通过反射调用任何其他方法。

Also the action that is mapped to the method can invoke any other methods directly or via reflection.

这篇关于在Action中调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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