由于之前在postman通过form-data的方式发送请求,参数是通过key-value的形式,在controller中通过@requestparam注解的 方式就可以取到值。如图


@RequestMapping(value = "/register", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String register(@RequestParam(value = "appSign", required = false) String appSign,
			@RequestParam(value = "pack", required = false) String pack,
			@RequestParam(value = "timestamp", required = false) Long timestamp,
			@RequestParam(value = "realname", required = false) String realname,
			@RequestParam(value = "gender", required = false) Integer gender,
			@RequestParam(value = "birthday", required = false) String birthday,
			@RequestParam(value = "cellphone", required = false) String cellphone,
			@RequestParam(value = "idNumber", required = false) String idNumber,
			@RequestParam(value = "type", required = false) String type,
			@RequestParam(value = "pin", required = false) Integer pin,
			@RequestParam(value = "addr", required = false) String address,
			@RequestParam(value = "imei", required = false) String imei,
			@RequestParam(value = "orgCode", required = false) String orgCode,
			@RequestParam(value = "status", required = false) String status,
			@RequestParam(value = "entityCardNum", required = false) String entityCardNum,
			@RequestParam(value = "showlog", required = false) String showlog
			)
            {
..............
}

后面需要调整为raw的那种请求方式,在controller取不到 ,网上查资料发现有一个@requestbody的注解可以实现这种方式的接收参数。


@RequestMapping(value="/sdktest",method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String sdktest(@RequestBody String json){
		
		System.out.println(json);
		return json;
		
	}

这种方式取到的是一个json字符串整体 ,拿到后就可以进行其他操作了。但是postman这两种的数据格式在网上查了查不是太明白什么意思。理解中的json就是一个字符串而已....只有先记录一下喽

在postman中返回的数据为


说明已经取到了,在eclipse后台打印的json也是这个值。
GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐