我从数据库中获取客户端名称列表,我需要将该列表填充到Play框架中的下拉列表中。当我这样做时,我收到一个错误:not found type name
。我做错了什么?
我的Application.java代码是:
package controllers;
import java.awt.List;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import play.mvc.*;
import play.twirl.api.Content;
public class Application extends Controller {
static List l = new List();
public static <list> Result index() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433","SUMEET","sumeet");
System.out.println(conn);
Statement sta = conn.createStatement();
String Sql = "select * from client";
ResultSet rs = sta.executeQuery(Sql);
while (((ResultSet) rs).next()) {
String ID= rs.getString("ClientName");
l.add(ID);
}
return ok((Content) l);
}
}
`
和我的index.scala.html
文件是
@import helper._ @main { @select( options(@message), '_label -> "Company", '_default -> "-- Choose a company --", '_showConstraints -> false ) }
答案 0 :(得分:0)
@(ConsultantList:java.util.List[String])
@import helper._
@main("ADAMS") {
---------
---------
@for(element <- ConsultantList){
<option value="@element">@element</option>
}