I need to read some data sent by the client using Spark (Java framework).
This is the client request code. I am using jQuery.
$.post("/insertElement", {item:item.value, value: value.value, dimension: dimension.value });
Server Code:
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 use Spark, so I need to determine the route. I would like to store data sent by the client in the database, but all attributes are null.
I think this way is wrong. How can I read the sent data?
source share