[英]How to POST a Java POJO / Json to a Play Framework v2.2.1 Controller Http POST Method
[英]POJO to JSON in Play framework
嘗試獲取Play 2.0以從POJO返回JSON。 但我收到錯誤
The method toJson(Writes<A>) in the type Json is not applicable for the arguments (Product)
我的代碼是:
public static Result index(String date) {
Product item = new Product();
return ok(Json.toJson(item));
}
有任何想法嗎?
確保使用import play.libs.Json
導入正確的Json
類。
您可能使用了針對Scala API(而非Java API)的play.api.libs.Json
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.