URL 当我在 eclipse DevMode 和 Tomcat 7 服务器上启动 gwt-rpc 项目时不同,所以我有 PayPal 问题

URL is different when I start gwt-rpc project in eclipse DevMode and on Tomcat 7 Server, so I have issues with PayPal

运行 在 Eclipse URL 上是:http://127.0.0.1:8080/MovieUniverse.html

运行 在 Tomcat 7 URL 上是:http://127.0.0.1:8080/MovieUniverse/MovieUniverse.html

我的问题是,当我使用 PayPal SDK 商家进行 Paypal Express Checkout 时,在服务器上我给执行 setCheckoutExpress 的方法一个 return URL 和一个取消 URL这样:

/*
        '------------------------------------
        ' The returnURL is the location where buyers return to when a
        ' payment has been succesfully authorized.
        '
        ' This is set to the value entered on the Integration Assistant 
        '------------------------------------
        */


        String returnURL = "http://127.0.0.1:8888/MovieUniverse.html#order_confirmed";

        /*
        '------------------------------------
        ' The cancelURL is the location buyers are sent to when they hit the
        ' cancel button during authorization of payment during the PayPal flow
        '
        ' This is set to the value entered on the Integration Assistant 
        '------------------------------------
        */
        String cancelURL = "http://127.0.0.1:8888/MovieUniverse.html#order_cancelled";
        /*
        '------------------------------------
        ' When you integrate this code 
        ' set the variables below with 
        ' shipping address details 
        ' entered by the user on the 
        ' Shipping page.
        '------------------------------------
        */
setExpressCheckoutRequestDetails.setReturnURL("http://127.0.0.1:8888/MovieUniverse.html#order_confirmed");


setExpressCheckoutRequestDetails.setCancelURL("http://127.0.0.1:8888/MovieUniverse.html#order_cancelled");

当我进行 Express Checkout 时,我离开了我的站点,在 paypal 付款确认后,该服务尝试加载 Return 或取消 URL 直到付款成功。所以系统尝试加载Return或者取消URL,但是自然这些URL在Server上是行不通的,因为路径不对(应该是http://127.0.0.1:8080/MovieUniverse/MovieUniverse.html#order_confirmed因为有用)。所以我需要一种方法让 URL 组成这样的字符串: URLGet+#order_confirmed 以获得正确的 URL 。或者也许另一种解决方案可以从一开始,当我调用 onModuleLoad() 时,从此方法内部更改 Url。 你有什么建议吗?非常感谢

解决方案一:将您的应用程序部署在 Tomcat 的“/”上下文根中,而不是“/MovieUniverse/”

解决方案二:在您的服务器上获取已部署应用程序的上下文路径,使用它来操作url。