[英]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.