阅读背景:

JAX-RS 服务接受json转换对象

来源:互联网 

其实挺小的一个细节,总算稀里糊涂做出来。

废话不多说了。

@Path("/alter")
	@POST
	@Produces("application/json")
	public Response alter(String jsonStr){
		//System.out.println(jsonStr);
		JSONObject json = JSONObject.fromObject(jsonStr);
		System.out.println(json);
		User user = (User)JSONObject.toBean(json,User.class);
		System.out.println(user.getNickName());
		return Response.status(200).entity(jsonStr).build();
	}@P



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: