zoukankan      html  css  js  c++  java
  • Why restTemplate.put() throws “HttpClientErrorException: 404 Not Found”

     

    I make a put request

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.put(new URI("http://localhost:8080/test"), dto);
    

    which successfully hits the rest endpoint

    @RequestMapping(value = "/test", method=RequestMethod.PUT)
    public void test123(@RequestBody DTO dto) {
        System.out.println("phone:"+dto.getPhone()); 
    }
    

    but the "put" method on the client throws exception, even though the server is hit successfully and I don't expect return value.

    Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found
        at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
        at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:589)
        at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:547)
        at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:518)
        at org.springframework.web.client.RestTemplate.put(RestTemplate.java:394)
        at com.my.Main.main(Main.java:45)

    查看连接路径是否正确。

  • 相关阅读:
    Python 更新pip报错:Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问
    Vs code 配置(1)-win10
    博客园主题--sukura
    log4j
    安装ant问题
    freemarker string= null
    学习随想
    j2ee学习资料收集
    eclipse + marven
    好文mark
  • 原文地址:https://www.cnblogs.com/tv151579/p/6124908.html
Copyright © 2011-2022 走看看