我是一个新手,已经开始开发一个应用程序来从数据库中获取数据。
我的应用程序中有以下代码:
public static Result list() {
List products = Productslist.getListOfProducts();
return ok(index.render(products));
}
这给了我以下错误:
Actual List cannot be converted to String on method invocation conversion
也可以查看我的 index.scala.html
#{extends 'main.html' /}
#{set title:'Cars in the car lot' /}
<h1>Products in Lot</h1>
<table border=1>
<tr>
<td>productname</td>
<td>Quantity</td>
<td>Price</td>
</tr>
#{list items:products, as:'product'}
<tr>
<td>${product.getProductname()}</td>
<td>${product.getQuantity()}</td>
<td>${product.getPrice()}</td>
</tr>
#{/list}
</table>
Application.java 的完整代码是:
package controllers;
import play.*;
import play.mvc.*;
import models.Productslist;
import views.html.*;
import views.*;
import java.util.*;
public class Application extends Controller
{
public static Result list()
{
List products = Productslist.getListOfProducts();
return ok(index.render(products));
}
}
谁能帮我找到错误的根源?