i have read data sent client using spark (a framework java).
this code of client's post request. using jquery.
$.post("/insertelement", {item:item.value, value: value.value, dimension: dimension.value }); the code of server:
post(new route("/insertelement") { @override public object handle(request request, response response) { string item = (string) request.attribute("item"); string value = (string) request.attribute("value"); string dimension = (string) request.attribute("dimension"); element e = new element(item, value, dimension); elementdao edao = new elementdao(); edao.insert(e); jsonobject json = jsonobject.fromobject( e ); return json; } }); i using spark have define route. store in database data sent client, attributes null.
i think way isn't correct. how can read sent data?
they way send data, using http post, you're posting json request body, not request attributes. means shouldn't use request.attribute("item") , others, instead parse request body java object. can use object create element , store using dao.
Comments
Post a Comment