首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

spring_mvc(3)Obtaining Request Data

2012-10-23 
spring_mvc(三)Obtaining Request DataObtained foo query parameter value barhttp://localhost:8080

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&param2=bar&param3=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;}

热点排行