Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7414

In http, put method can have request body but RequestParam Annotation doesn't work

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Web
    • Labels:
      None

      Description

      @RequestMapping(value="/put", method=RequestMethod.PUT)
      @ResponseBody
      public Result testPutParam(@RequestParam("name") String name)

      { Map<String, String> m = new HashMap<String, String>(); m.put("name", name); m.put("msisdn", "010-7464-5279"); return new SuccessResult<Map<String, String>>(m); }

      RequestParam annotation doesn't work.

      if I use RequestBody annotation instead, I can see request body

      I call this api as below

      HttpPut httpPut = new HttpPut("http://localhost:8080/put");
      httpPut.addHeader("Accept", "application/json");

      // Add data
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
      nameValuePairs.add(new BasicNameValuePair("name", "louisHuh"));
      httpPut.setEntity(new UrlEncodedFormEntity(nameValuePairs));

      HttpClient client = new DefaultHttpClient();
      HttpResponse response = client.execute(httpPut);

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              louishuh Louis Huh
              Last updater:
              Arjan van B.
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 years, 17 weeks, 6 days ago