我是玩框架的新手。我想将 java 控制器中的数组变量传递给 scala 模板。
try {
String userName = "data";
String password = "data";
String url = "jdbc:mysql://localhost/playdb";
// Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection(url, userName, password);
Statement stmt = con.createStatement();
System.out.println("Connected database successfully...");
String strSelect = "select * from computer";
//statement.setString(1, name);
ResultSet rset = stmt.executeQuery(strSelect);
while(rset.next()) { // Move the cursor to the next row
String name = rset.getString("name");
int id = rset.getInt("id");
System.out.println( name + ", " + id);
// ++rowCount;
}
}
catch(SQLException e) {
e.printStackTrace();
System.out.println("cant Connected database successfully...");
}
Form<Computer> computerForm = form(Computer.class);
return ok(
createForm.render(computerForm,rset)
);
和 scala Templete
@(computerForm: Form[Computer],createFormRset: String)
我得到了错误
cannot find symbol [symbol: variable rset] [location: class controllers.Application]
我需要将rset
值传递给 scala template 。但我不知道如何请帮助我