此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【kunmingkunlun】截止到2008-07-01 18:18:12的历史汇总数据(不包括此帖):
发帖数:42 发帖分:1040
结贴数:10 结贴分:230
未结数:32 未结分:810
结贴率:23.81 % 结分率:22.12 %
楼主该结一些帖子了
楼主【kunmingkunlun】截止到2008-07-01 18:18:12的历史汇总数据(不包括此帖):
发帖数:42 发帖分:1040
结贴数:10 结贴分:230
未结数:32 未结分:810
结贴率:23.81 % 结分率:22.12 %
楼主该结一些帖子了
解决方案 »
- 问一个简单的hql查询
- 高分请教关于many-to-one 和 one-to-many 成对的问题!
- struts2 提交验证问题
- 帮我看下这个错误:java.lang.ClassCastException: org.apache.struts.action.ActionMessage
- tomcat下如何配置多个数据源
- jdbc中的connection可以使用单例模式么
- 谁来帮我看看这个ejb客户端测试程序出错的原因是什么。。。
- EJB的防问和防火墙
- 发生空指针异常这是怎么回事
- 新人请教 Java MySQL创建数据库
- +++++ tomcat下开发的web应用怎样发布到websphere上
- 大家分析下我的日志文件,看看为什么程序执行了两次
/**
* 生成HTML的table
*
* list : 实体类集合
* columnsToShow : 需要显示那些列,大小写敏感,交换顺序后表格顺序也交换
* columnNames : 表头名称,需要和 columnsToShow 长度对应。如果为null,则显示列名
*
* /
public String createTableByListAndColumnNames(List list,
String[] columnsToShow, String[] columnNames) {
String table = "<table cellpadding=\"1\" cellspacing=\"1\" bgColor=\"#CCCCCC\" width=\"100%\">\n"; // 如果得到的list不为空,且数量大于0
if (list != null && list.size() > 0) {
// 得到List中的bean类
Class c = list.get(0).getClass(); // bean类中的所有方法,包括父类方法
Method[] m = c.getMethods(); // 将columnsToShow转换为Vector,方便下面的操作
Vector columnsToShowVector = new Vector();
for (int i = 0; i < columnsToShow.length; i++) {
// 首字母大写,并加上“get”,方便下面的比较
String column = "get"
+ ("" + columnsToShow[i].charAt(0)).toUpperCase()
+ columnsToShow[i].substring(1);
columnsToShowVector.add(column);
} // bean中所有以get开头的方法,不包括getClass和get方法,且必须在columnsToShow参数中指定
Vector allGets = new Vector(); for (int i = 0; i < m.length; i++) {
String currentMethodName = m[i].getName();
if (currentMethodName.startsWith("get")
&& !currentMethodName.equals("getClass")
&& !currentMethodName.equals("get")
&& columnsToShowVector.contains(currentMethodName)) {
allGets.add(m[i]);
}
} // 设置表头名
if (columnNames != null) {// 如果手动设置了表头名
table += "\t<tr>\n";
for (int i = 0; i < columnNames.length; i++) {
table += "\t\t<td bgColor=\"#E7EFFF\">\n";
table += "\t\t\t<a href=\"javascript:newOrder('" + (i + 1)
+ "')\">" + columnNames[i] + "</a>\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
} else {// 如果没有手动设置表头名,则用默认名(使用bean中的属性名)
table += "\t<tr>\n";
for (int i = 0; i < allGets.size(); i++) {
Method currentMethod = (Method) allGets.get(i);
table += "\t\t<td bgColor=\"#E7EFFF\">\n";
table += "\t\t\t<a href=\"javascript:newOrder('" + (i + 1)
+ "')\">" + currentMethod.getName().substring(3)
+ "</a>\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
} try {
// 从list中取数据放到表中
for (int i = 0; i < list.size(); i++) {
table += "\t<tr>\n";
for (int j = 0; j < allGets.size(); j++) {
Method currentMethod = (Method) allGets.get(j);
table += "\t\t<td bgColor=\"#FFFFFF\">\n";
table += "\t\t\t"
+ currentMethod.invoke(list.get(i), null)
+ "\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
table += "</table>\n";
return table;
}
* 生成HTML的table
*
* list : 实体类集合
* columnsToShow : 需要显示那些列,大小写敏感,交换顺序后表格顺序也交换
* columnNames : 表头名称,需要和 columnsToShow 长度对应。如果为null,则显示列名
*
*/
public String createTableByListAndColumnNames(List list,
String[] columnsToShow, String[] columnNames) {
String table = "<table cellpadding=\"1\" cellspacing=\"1\" bgColor=\"#CCCCCC\" width=\"100%\">\n"; // 如果得到的list不为空,且数量大于0
if (list != null && list.size() > 0) {
// 得到List中的bean类
Class c = list.get(0).getClass(); // bean类中的所有方法,包括父类方法
Method[] m = c.getMethods(); // 将columnsToShow转换为Vector,方便下面的操作
Vector columnsToShowVector = new Vector();
for (int i = 0; i < columnsToShow.length; i++) {
// 首字母大写,并加上“get”,方便下面的比较
String column = "get"
+ ("" + columnsToShow[i].charAt(0)).toUpperCase()
+ columnsToShow[i].substring(1);
columnsToShowVector.add(column);
} // bean中所有以get开头的方法,不包括getClass和get方法,且必须在columnsToShow参数中指定
Vector allGets = new Vector(); for (int i = 0; i < m.length; i++) {
String currentMethodName = m[i].getName();
if (currentMethodName.startsWith("get")
&& !currentMethodName.equals("getClass")
&& !currentMethodName.equals("get")
&& columnsToShowVector.contains(currentMethodName)) {
allGets.add(m[i]);
}
} // 设置表头名
if (columnNames != null) {// 如果手动设置了表头名
table += "\t<tr>\n";
for (int i = 0; i < columnNames.length; i++) {
table += "\t\t<td bgColor=\"#E7EFFF\">\n";
table += "\t\t\t<a href=\"javascript:newOrder('" + (i + 1)
+ "')\">" + columnNames[i] + "</a>\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
} else {// 如果没有手动设置表头名,则用默认名(使用bean中的属性名)
table += "\t<tr>\n";
for (int i = 0; i < allGets.size(); i++) {
Method currentMethod = (Method) allGets.get(i);
table += "\t\t<td bgColor=\"#E7EFFF\">\n";
table += "\t\t\t<a href=\"javascript:newOrder('" + (i + 1)
+ "')\">" + currentMethod.getName().substring(3)
+ "</a>\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
} try {
// 从list中取数据放到表中
for (int i = 0; i < list.size(); i++) {
table += "\t<tr>\n";
for (int j = 0; j < allGets.size(); j++) {
Method currentMethod = (Method) allGets.get(j);
table += "\t\t<td bgColor=\"#FFFFFF\">\n";
table += "\t\t\t"
+ currentMethod.invoke(list.get(i), null)
+ "\n";
table += "\t\t</td>\n";
}
table += "\t</tr>\n";
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
table += "</table>\n";
return table;
}