【问题标题】:Redirect to Struts 2 action class after user completes PayPal purchase用户完成 PayPal 购买后重定向到 Struts 2 动作类
【发布时间】:2015-01-26 19:53:48
【问题描述】:

我在我的 Struts 2 Web 项目中使用 PayPal Sandbox。

我有一个包含 PayPal 表单的 payment-method.jsp

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">     
    <!-- other stuff -->

    <input type="hidden" name="return" value="payment">
    <input type="hidden" name="cancel_return" value="http://localhost:8080/mysite/payment-method.jsp">

    <!-- payment button -->                     
</form>

我已将return 值指定为payment

我在struts.xml 中定义了操作:

<action name="payment" class="com.mypackage.action.PaymentAction">
    <result>/transaction-result.jsp</result>
</action>

但它正在返回 PayPal Sandbox 主页。

在用户在 PayPal 中完成交易后,我如何重定向到某个操作(而不是实际页面)?

(顺便说一句,cancel_return 工作。)

【问题讨论】:

  • 您想重定向到jsp 或其他操作?
  • return,我想重定向到一个动作。
  • 那么在这种情况下,您需要将&lt;action name="payment" class="ph.watchy.action.PaymentAction"&gt; &lt;result&gt;/transaction-result.jsp&lt;/result&gt; &lt;result name="index" type="redirect"&gt;/index.jsp&lt;/result&gt; &lt;/action&gt; 更改为&lt;action name="payment" class="ph.watchy.action.PaymentAction"&gt; &lt;result&gt;/transaction-result.jsp&lt;/result&gt; &lt;result name="index" type="redirect"&gt;ActionName to which you want redirect&lt;/result&gt; &lt;/action&gt;

标签: java jsp redirect paypal struts2


【解决方案1】:

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/ProfileAndTools/

首先阅读此文档并在您的贝宝帐户中提供您的操作网址作为回报网址。

并将自动返回设置为开启。

不,如果你有实时 url,你不能在 localhost 上查看,然后在 live 上查看。

【讨论】:

  • 嗨,我的网络项目还没有上线,上面的 url 有效。我接受这个答案是因为“在您的贝宝帐户中提供您的操作网址作为回报网址” 是线索。谢谢。
【解决方案2】:

如果你想重定向到行动,那么

你改变这个

 <action name="payment" class="ph.watchy.action.PaymentAction">
<result>/transaction-result.jsp</result>
<result name="index" type="redirect">/index.jsp</result>

  <action name="payment" class="ph.watchy.action.PaymentAction">
   <result>/transaction-result.jsp</result>
   <result name="index" type="redirect">ActionToberedireected</result>
  </action>

执行操作而不是您要重定向到的 index.jsp ..

【讨论】:

    猜你喜欢
    • 2012-07-17
    • 2010-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    相关资源
    最近更新 更多