码迷,mamicode.com
首页 > 编程语言 > 详细

spring @RequestBody的使用

时间:2015-02-06 23:18:38      阅读:1059      评论:0      收藏:0      [点我收藏+]

标签:

@RequestMapping(value="/testJson",produces="application/json")
	public String testJson(@RequestBody AccountTest test){
		System.out.println(test.getUsername());
		return "index";
	}

研究了下这个的使用:

如果http请求body传的是json的话就得使用他来接受了,可以直接用String参数来接受,在方法体内自己进行转换,也可以直接让spring进行转换参数直接设置为bean。但是如果参数直接是bean的话,得加入jackson的包

spring @RequestBody的使用

标签:

原文地址:http://my.oschina.net/hhdys412/blog/376244

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!