平时做的下拉列表里的数据都来自固定的codelist.最近客户要求只显示他们已有的. 比如年度,数据库里只有1999-2007的数据,而我们自己设置的话,设置多少年都不合适,1980-2050 ? 太长了吧,系统也用不到那个时候,下拉的时候选择也不方便..其实可以考虑从数据库里读. public List
public List getNappcList(){ //liangsai:20080516 取补助批次
String hql= "select distinct t from BzPfxx t where t.nappc is not null order by t.nappc asc ";//
List list=getHibernateTemplate().find(hql);
return list;
}
/**
然后在ManagerImplpublic List getNappcList(){
List list = dao.getNappcList();
List newlist = new ArrayList();
String mystr="";
for (int i=0;i<list.size();i++){
BzPfxx pf = (BzPfxx)list.get(i);
if ( mystr.indexOf(pf.getNappc().toString())==-1){ //
newlist.add(new LabelValueBean(pf.getNappc(),pf.getNappc()));
}
mystr=mystr+pf.getNappc();
}
return newlist;
}
用了一个很笨的方法去掉重复的数据...我坚信有个简单的,可我也不知道..对list真的不熟