当前位置:   article > 正文

解决:org.springframework.web.client.HttpClientErrorException: 405 null at org.springframework.web.clie

org.springframework.web.client.httpclienterrorexception$methodnotallowed: 40

org.springframework.web.client.HttpClientErrorException: 405 null at org.springframework.web.client

排查了下原因
造成错误的原因:controller层请求 是标识 RequestMethod.POST的请求

@RequestMapping(value = "/downloadFile", method = RequestMethod.POST)
    public void downloadFile(HttpServletRequest request, HttpServletResponse response,
                             @RequestParam(value = "service_name", required = false) String serviceName,
                             @RequestParam("operator_code") String operatorCode)
            throws UnsupportedEncodingException {
  • 1
  • 2
  • 3
  • 4
  • 5

然而在执行:内部发起请求的时候

            ResponseEntity<String> res = restTemplate.postForEntity(fileTransferBO.getFlmServerAddress(), ExcelUtils.createFileHttpParam(fileTransferBO), String.class);
  • 1

请求所调用的接口方式是:method = RequestMethod.GET

@RequestMapping(value = "/getFileInfo", method = RequestMethod.GET)
    @ResponseBody
    public ApiResult getFileInfo(@RequestBody() FileTransferBO fileTransferBO) {
  • 1
  • 2
  • 3

所以报这个错误。
解决:
这里把内部所调用的请求方式和controller层的调成一致即可解决该问题。

@RequestMapping(value = "/getFileInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getFileInfo(@RequestBody() FileTransferBO fileTransferBO) {
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/364213
推荐阅读
相关标签
  

闽ICP备14008679号