spring_mvc(三)Obtaining Request Data
Obtained 'foo' query parameter value 'bar'
http://localhost:8080/spring_mvc_test/data/param?foo=test
结果:Obtained 'foo' query parameter value 'test'
Obtain parameter group Param1:foo, Param2:bar, Params:baz
http://localhost:8080/spring_mvc_test/data/group?param1=foo¶m2=bar¶m3=baz
JavaBean:
Obtained 'Accept'header 'text/plain, */*'
http://localhost:8080/spring_mvc_test/data/header
Obtained 'Accept' header 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*'
posted request body 'foo'
结果:body:aaa=aaasdfasf
Request Body and Headers
@RequestMapping(value="form", method=RequestMethod.POST)
public @ResponseBody String withEntity(@RequestBody MultiValueMap<String, String> form) {
String message = "read from map" + form;
return message;
}
read from map{aaa=[qqq], bbb=[www]}
write a form
http://localhost:8080/spring_mvc_test/data/form@RequestMapping(value="/form", method=RequestMethod.GET)public @ResponseBody MultiValueMap<String, String> writeForm() { MultiValueMap<String, String> map = new LinkedMultiValueMap<String , String>(); map.add("foo", "bar"); map.add("fruit", "apple"); return map;}