您可以使用POST而不是GET进行struts2动作重定向吗? [英] Can you do a struts2 action redirect using POST instead of GET?

查看:178
本文介绍了您可以使用POST而不是GET进行struts2动作重定向吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<action name="actionA" class="com.company.Someaction">
 <result name="success" type="redirect-action">
  <param name="actionName">OtherActionparam>
  <param name="paramA">${someParams}</param>
  <param name="paramB">${someParams}</param>
  <param name="aBoatLoadOfOtherParams">${aBoatLoadOfOtherParams}</param>
 </result>
</action>

在上面的动作图中,我从SomeAction重定向到OtherAction.我遇到了问题,因为不幸的是,我需要在两个操作之间传递大量数据. IE7将只允许GET请求达到2k,因此当我刚刚超过该限制(响应响应将get请求发送给其他操作)时,它就会爆炸.

我是否可以设置此重定向,最终导致调用POST来执行其他操作?

解决方案

作为 动作链接 ?我不确定,通常不建议这样做,但是您的情况似乎很不寻常,因此可能值得一看.

在这种情况下,我们并没有真正进行重定向,即我们没有返回到客户端,而是将所有内容保留在服务器中.然后,应该再次执行完整的拦截器堆栈-并且发布的数据应该会影响新的动作,人们希望...

<action name="actionA" class="com.company.Someaction">
 <result name="success" type="redirect-action">
  <param name="actionName">OtherActionparam>
  <param name="paramA">${someParams}</param>
  <param name="paramB">${someParams}</param>
  <param name="aBoatLoadOfOtherParams">${aBoatLoadOfOtherParams}</param>
 </result>
</action>

In the above action map, I am redirecting from SomeAction to OtherAction. I am having issues, because unfortunately I need to pass a large amount of data between the two actions. IE7 will only allow GET requests to be like 2k, so its blowing up when I'm just over that limit when the response calls a get request to the other action.

Is it possible for me to set this redirect, to end up with a POST being called to the other action?

解决方案

As the docs states:

The only way to pass data [after a redirection] is through the session or with web parameters (url?name=value) [i.e., query string for a GET request]

Perhaps a case for action chaining? I'm not sure, and it's not usually recommended, but it seems that you scenario is rather unusual, so it might pay to take a look.

In this case, we are not really making a redirection, i.e., we are not going back to the client, but keeping everything inside the server. Supposedly, then, the full interceptor stack is executed again - and the posted data should impact on the new action, one would hope...

这篇关于您可以使用POST而不是GET进行struts2动作重定向吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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