Announcement Announcement Module
Collapse
No announcement yet.
put request problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • put request problem

    I wrote below method in my controller

    Code:
    	@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);
    	}
    and if i call this url with querystring it works very well,
    but if i call this url with request body, it doesn't work.

    I think that put method can have request body such as post.

    below is test code with HttpClient

    Code:
            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);
    put method can't have request body?

    thanks
    Last edited by Louis Huh; Aug 2nd, 2010, 10:02 AM.
Working...
X