我正在从数据库中获取客户端名称列表,并且需要将该列表填充到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 ) }
@(ConsultantList:java.util.List[String])
@import helper._
@main("ADAMS") {
---------
---------
@for(element <- ConsultantList){
<option value="@element">@element</option>
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句