0

我的路线 POST /article/create Application.create

应用程序.java 文件

public static void create(Article article) {
   article.save();
  //send article ID (article.id) after saving

}

文章保存在数据库中后,是否可以将 article.id 作为响应发送给客户端?如果是,最好的方法是什么

4

1 回答 1

1

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

  • headers
  • body of response
  • or even cookies

Inside body you can return just id, or embed id inside json, xml, html or some other data structure.

于 2013-11-13T19:27:13.540 回答