对于返回网址,您似乎必须像这样定义整个网址:
String returnURL = "http://localhost:8080/appName/shopping/confirmorder";
现在,我的请求映射存在问题:
@RequestMapping(value = "/shopping/confirmorder?token={token}&PayerID={payerID}", method = RequestMethod.GET)
public String doGet(@PathVariable("token") String token, @PathVariable("payerID") String payerID,
HttpServletRequest request) {
// do stuff
}
由于某种原因,永远不会调用控制器?
从Paypal返回的最终returnURL是这样的:
http://localhost:8080/appName/shopping/confirmorder?token=EC-4...G&PayerID=A...W
注意Ids已被编辑。
答案 0 :(得分:1)
如果您有两个名为token
和payerID
的路径变量,那么方法签名应为
public void doGet(@PathVariable("token") String token,
@PathVariable("payerID") String token,
HttpServletRequest request,
HttpServletResponse response)
您是如何期望Spring将这两个字符串放在option
类型的int
个参数中?
此外,PathVariable用于将请求路径的部分绑定到方法参数。在您的情况下,您有请求参数。因此,您应该使用@RequestParam:
@RequestMapping(value = "/shopping/confirmorder", method = RequestMethod.GET)
public void doGet(@RequestParam("token") String token,
@RequestParam("PayerID") String token,
HttpServletRequest request,
HttpServletResponse response)