求大侠帮忙看看
[关注官方微博]
[1千金币=1元]
[上传资源赚钱]
javabean的部分代码sbglUtil 类的部分代码
public Collection getAllsbgl() throws Exception {
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery("select * from sbtj");
Collection ret = new ArrayList();
while (rst.next()) {
sbgl tempSt = new sbgl();
tempSt.setid(rst.getString("id"));
tempSt.setname(rst.getString("name"));
tempSt.setrkdate(rst.getString("rkdate"));
tempSt.setsbxh(rst.getString("sbxh"));
tempSt.setscdate(rst.getString("scdate"));
tempSt.setsblx(rst.getString("sblx"));
tempSt.setgs(rst.getString("gs"));
tempSt.setbm(rst.getString("bm"));
tempSt.setsbzt(rst.getString("sbzt"));
tempSt.setczid(rst.getString("czid"));
ret.add(tempSt);
}
stmt.close();
con.close();
return ret;
}
-----------------------
sbgl 类中的部分代码
}
public String getbm() {
return bm;
}
public String getsbzt() {
return sbzt;
}
public String getczid() {
return czid;
}
public void setscdate(String scdate) {
this.scdate = scdate;
}
public void setname(String name) {
this.name = name;
}
public void setrkdate(String rkdate) {
this.rkdate = rkdate;
}
public void setsbxh(String sbxh) {
----------------------------------------------------------------------------
jsp部分代码
Collection sbgls=sbglUtil.getAllsbgl();
Iterator it=sbgls.iterator();
while(it.hasNext())
{
sbgl temp=(sbgl)it.next();
out.println("<tr>");
try
{
jsp报错
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 31 in the jsp file: /viewStudent.jsp
sbgl cannot be resolved to a type
28: Iterator it=sbgls.iterator();
29: while(it.hasNext())
30: {
31: sbgl temp=(sbgl)it.next();
32: out.println("<tr>");
33:
34: try
[解决办法]
应该迭代 ret 这个吧 。 Collection ret = new ArrayList();
[解决办法]
Collection<sbgl> ret = new ArrayList<sbgl>();想强转用泛型