Struts 2 - 动态设置方法名,从一个Action调用另一个Action方法,执行
我有一个关于 Struts 2 方法调用的疑问。 假设我想动态调用方法,并且该方法名称将来自数据库。所以情况是, 有一个主模块和2个子模块,比如说M1和M2,现在来自任何模块的每个请求都将通过主模块,所以如果模块M1询问方法名称,假设getName()仅存在于M2动作类中,(这里是M1不知道),那么首先M1会向Master模块发送一个请求(以方法名作为参数),然后Master模块会找出这个请求是针对哪个方法的,然后他会调用M2的getName()方法。为此,我们不需要将 getName() 方法映射到 Struts.xml 中,我们必须在主模块的 Action 类中设置它。我无法理解如何执行此操作,因为每次主模块都会获取一些方法名称(作为参数)并调用包含该方法名称的相应操作。 请帮忙
谢谢 塔潘
I have one query regarding Struts 2 method invocation.
Suppose i want to call method dynamically and that method name will come from DB. so the scenario is,
there is one Master module and 2 sub modules lets say M1 and M2, Now every request from any module will go through Master Module, so if module M1 ask for method name suppose getName() which exist in M2 action class only, (here M1 is not aware about it), then first M1 will send a request to Master Module (with method name as a parameter) then master module will find out for which method this request is for and then he will call M2 getName() method. To do this we dont need to Map method getName() into Struts.xml, We have to set this in Action class of Master Module. I am not able to understand how to do this Cause every time Master Module will get some method name (as Parameter) and will call respective action which include that method name.
Please Help
Thanks
Tapan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
国际海事组织:
您可以使用以下技术动态传递方法名称
如果action =“customerActiongetCustomerName.do”,
IMO:
you can dynamically pass the method name using below technique
if action="customerActiongetCustomerName.do