我想在POST方法上采取JSON值,但我不知道如何做到这一点。JSON与@POST Restful
这是我的代码:
@POST
@Path("/contacts")
@Consumes({"application/json"})
public void addContact() {
HttpSession session = request.getSession(true);
UserPK user = new UserPK((String) session.getAttribute("username"));
//dest = TAKE JSON VALUE
dao.addContact(user, dest);
}
我送与Firefox RESTClient实现的JSON值这个样子:
{"param1":"value"}
我怎么能采取这种价值?
我们也有这样的错误消息:415不支持的媒体类型
感谢。
你能解释一下更多?是“dest”你的JSON对象还是ju st从您提取的JSON对象获取值?错误消息何时发生? – Alex1620