我的路线
POST /article/create Application.create
应用程序.java 文件
public static void create(Article article) {
article.save();
//send article ID (article.id) after saving
}
文章保存在数据库中后,是否可以将 article.id 作为响应发送给客户端?如果是,最好的方法是什么
我的路线
POST /article/create Application.create
应用程序.java 文件
public static void create(Article article) {
article.save();
//send article ID (article.id) after saving
}
文章保存在数据库中后,是否可以将 article.id 作为响应发送给客户端?如果是,最好的方法是什么
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.