【问题标题】:org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supportedorg.springframework.web.HttpRequestMethodNotSupportedException:不支持请求方法“POST”
【发布时间】:2020-10-29 03:40:52
【问题描述】:

我正在 Hybris 中进行第三方支付集成 Adyen,在成功进行 3D 安全验证后,发卡机构会将购物者重定向到我们的网站。在这种情况下,我将收到对我在 returnURl 中指定的 URL 的 HTTP POST 调用,在我的情况下是 https://localhost:9002/test/en/EUR/payment/submitResponse

发卡机构对我们 URL 的 HTTP POST 调用包括以下参数:

  1. MD – 发卡机构返回的支付会话标识符。
  2. PaRes – 发卡机构返回的付款授权响应。

请求标头:

Content-Type: application/x-www-form-urlencoded
Origin: https://test.test.com
Referer: https://test.test.com/hpp/3d/authenticate.shtml
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/83.0.4103.116 Safari/537.36
Form Data->
MD: SomeString
PaRes: SomeString

控制器注解:

@Controller
@RequestMapping(value = "/payment") 

方法:

@ResponseBody
    @RequestMapping(value = "/submitResponse", method = RequestMethod.POST)
    public Map<String, Object> submitResponse(final HttpServletRequest request) {
        Map<String, Object> responseMap = new HashMap<>();
        responseMap.put("Key", "hello im submitted");
        return responseMap;
    }

我检查了来自 Adyen 的 POST 请求的标头,发现了表单数据:

md="SomeString"
Pares="someString"

但是,我收到以下异常:

WARN  [hybrisHTTP34] [DefaultHandlerExceptionResolver] Resolved exception caused by handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported

在浏览器控制台中:

Failed to load resource: the server responded with a status of 405 ()

【问题讨论】:

  • 你的控制器注释上有什么?
  • @Controller @RequestMapping(value = "/payment")
  • 看不到缺少什么...尝试获取...看看会是什么结果。通常当弹簧加载时,你会得到一个包含所有映射 url 的日志
  • 是的,它适用于 GET,但我的要求是使用 POST
  • 您检查访问日志中调用的 URL 了吗? /hybris/log/tomcat/accessXXXX.log

标签: spring spring-mvc model-view-controller payment 3d-secure


【解决方案1】:

感谢大家的回复,我将 CSRF 令牌传递给 Adyen 请求,它开始工作了。

【讨论】:

    猜你喜欢
    • 2021-09-20
    • 2020-05-19
    • 2022-01-15
    • 1970-01-01
    • 2022-01-06
    • 2020-12-23
    • 2019-05-07
    相关资源
    最近更新 更多