Reputation: 1346
My route
POST /article/create Application.create
Application.java file
public static void create(Article article) {
article.save();
//send article ID (article.id) after saving
}
Is it possible to send article.id as a response to the client once the article has been saved in the DB? If yes, what is the best way to do it
Upvotes: 0
Views: 514
Reputation: 366
You didn't specify which version of play you are using, but if it's play2 your method signature looks like missing return type.
Please see more from here, and decide yourself how you want to return newly created id
http://www.playframework.com/documentation/2.2.x/JavaResponse
You have several possibilities to return id
Inside body you can return just id, or embed id inside json, xml, html or some other data structure.
Upvotes: 1