在这段代码中,我声明了一个变量,它包含List的值acode
。我可以看到此List中的值,但我不知道如何使用adao.adao.findAllacctDesc(**acode**)
迭代值。我如何迭代这个列表,以便选项显示值?
以下是代码:
<%
TblTaxTypeDAO tdao = DAOFactory.getDaoManager(TblTaxType.class);
TblAccountCodesDAO adao = DAOFactory.getDaoManager(TblAccountCodes.class);
List<TblTaxType> acode = null;
String tcode = request.getParameter("taxt");
String bcode = request.getParameter("bfns");
acode = tdao.findAllAcctCode(bcode, tcode);
Debugger.print(acode);
List<TblAccountCodes> acctdesclist = null;
acctdesclist = adao.findAllacctDesc(acode); <= Having error in this line because acode is a list not a string.
String acctdescoptions = "";
if( acctdesclist!=null) {
if( acctdesclist.size()>0 ) {
for(int i=0; i<acctdesclist.size();i++) {
TblAccountCodes acctcode = (TblAccountCodes) acctdesclist.get(i);
acctdescoptions += "<option value='"+acctcode.getAcctCode()+"'>"+acctcode.getAcctDesc()+"</option>";
acctcode = null;
}
}
}
adao = null;
acctdesclist = null;
%>
<%=acctdescoptions%>
答案 0 :(得分:0)
更改
List<TblAccountCodes> acctdesclist = null;
acctdesclist = adao.findAllacctDesc(acode); <= Having error in this line because acode is a list not a string.
通过
List<TblAccountCodes> acctdesclist = null;
for(TblTaxType T:acode){
acctdesclist.add(adao.findAllacctDesc(T.getString))
}
这是你想要的吗?
其中getString是TblTaxType中的函数,您可以在其中返回所需的字符串。