一个接一个地执行多个动作 [英] Executing multiple actions one after another

查看:43
本文介绍了一个接一个地执行多个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种通过一个请求执行多个 struts 操作的方法.目标是最小化对服务器的请求需求.所以我需要的是像MultiAction"这样的东西,它获取一个动作列表作为它应该执行的参数,然后返回这个动作的组合"结果.

I am in need of a way of executing multiple struts actions with one request. The goal is to minimize the need of request against the server. So what i need is something like a "MultiAction" which gets a list of actions as its parameters which it should execute and then return a "combined" result of this actions.

例如:

  • 客户端被分成很多模块
  • 一个模块需要从服务器获取信息
  • 在处理这个请求的客户端有一个代理
  • 这个代理现在会说嘿​​,你们其他模块,我要向服务器发出请求,你们需要什么吗?"
  • 其他模块现在可以选择向代理提交请求
  • 然后将实际的组合"请求发送到服务器,结果再次拆分并提供给请求它的模块

所以我的问题是:

  1. 在 Struts2 中是否有标准的方法来做这样的事情?
  2. 是否有一种标准的公开"方式来手动调用另一个操作并从值堆栈中获取其结果?

推荐答案

这可以通过在结果类型中使用redirectAction"来实现.以下代码是相同的示例.您必须根据您使用嵌套操作的要求在 struts XML 中配置操作标签.

This can be achieved by using "redirectAction" in result type. following code is the example for same. you have to configure action tag in struts XML according to your requirement of using nested Actions.

     <action name="userHomeAction" class="com.etp.connect.struts.action.UserHomeAction">
        <result type="redirectAction" name="SUCCESS_EDIT">
            <param name="actionName">getUserEditData</param>
            <param name="selectedUser">${selectedUser}</param>        
        </result>
        <result name="error">/jsp/userMgmt/Users_Home.jsp</result>
        <result name="login">/jsp/loginMgmt/Login.jsp</result>
    </action>

这篇关于一个接一个地执行多个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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