我写了这样的Bean
package mfkvit;
import java.sql.*;
import java.util.ArrayList;
public class outCentent {
private String title = "",self="",empty="";
private int id,colLen=0;
private ArrayList result = new ArrayList();
public int getID() {
return id;
}
public void setID(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public void search(String title, int id) {
Statement smt = null;
ResultSet rs = null;
try {
ConnectionManager.getConnection();
String sql = "select top " + id + " from addKultar where title='"
+ title + "'";
rs = smt.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
colLen = rsmd.getColumnCount();
while(rs.next()){
String[] colValue = new String[colLen];
for (int i = 0; i < colLen; i++) {
colValue[i] = ((self = rs.getString(i + 1)) == null ? empty
: self.trim().length() == 0 ? empty : self.trim());
}
result.add(colValue);
System.out.print("OK!");
}
} catch (Exception e) {
}
}
public ArrayList getRS() {
return result;
}
}
在面中调用
jsp:useBean id="outCentent" class="mfkvit.outCentent" scope="page">
<jsp:setProperty name="outCentent" property="*"/>
</jsp:useBean>
<%
outCentent.setID(6);outCentent.setTitle("税务文化");
outCentent.search("税务文化",6);
ArrayList al = outCentent.getRS();
for (int i = 0; i < 6; i++) {
HashMap colValue = (HashMap) al.get(i);
String note = (String) colValue.get("title");
%>
出错了:org.apache.jasper.JasperException: Unable to compile class for JSP:
以前没有过HashMap,在这里感觉是输出我的结果集,可是正确的写法应该是怎么样的?