各位前辈,请问一下。我想让前台调用后台的方法,给后台传入一个参数,然后后台返回数据库中,一个表的所有字段的名字。
但是,后台的数据,传递不到前台。请问一下,可以传list类型吗?
```
public List quarryTableName(String tableName)
{
List<String> list = null;
//Dao dao = new NutDao();
//private Dao dao;
//查询ofbiz中所有表名
Sql sql1 = Sqls.create("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ofbiz'");
//查询表中所有字段名
Sql sql2 = Sqls.create("select COLUMN_NAME from information_schema.COLUMNS where table_name = @tableName and table_schema = 'ofbiz'");
sql2.vars().set("tableName", tableName);
sql1.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<String> list1 = new ArrayList<String>();
while (rs.next())
list1.add(rs.getString("TABLE_NAME"));
return list1;
}
});
//执行sql1
dao_td.execute(sql1);
//接收
List<String> listSql1 = sql1.getList(String.class);
for (int i = 0; i < listSql1.size(); i++) {
String tn=listSql1.get(i);
if (tableName==tn) {
sql2.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<String> list2 = new ArrayList<String>();
while (rs.next())
list2.add(rs.getString("TABLE_NAME"));
return list2;
}
});
dao_td.execute(sql2);
List<String> listSql2 = sql2.getList(String.class);
list = listSql2;
}else{
}
}
return list;
}