try{ String sql="select goodsname,introduction,unit,company,price,total from goods ";
st=cql.executeQuery(sql);
while(st.next()){
gb.setGoodsname(st.getString("goodsname"));
gb.setGoodsname(st.getString("unit"));
gb.setGoodsname(st.getString("introduction"));
gb.setGoodsname(st.getString("company"));
gb.setGoodsname(st.getString("price"));
gb.setGoodsname(st.getString("total"));
al.add(gb);
}
} catch(SQLException e){
System.out.println("the sql error:"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
return al;
}
}
页面SCOPE我用的是REQUEST啊
<% int i=0;
int a;
int j=0;
ArrayList al=new ArrayList();
al=lookup.gethash();
Object ia[]=al.toArray();
a=ia.length; %>
function lookup(){
var index=<%=a%>;
var n=0;
document.write("<table width=500 height=500 border=1 align=center><tr>");
document.write("<th>商品名称</th><th>价格</th><th>计量单位</th><th>库存</th><th>产品介绍</th><th>生产厂家</th><tr>");
for(n=0;n<index;n++)
{
document.write("<td><%=gb.getGoodsname()%></td><td colspan=1><%=gb.getPrice()%></td><td><%=gb.getUnit()%></td><td><%=gb.getTotal()%></td><td colspan=1><%=gb.getIntroduction()%></td><td><%=gb.getCompany()%></td></table>");
}
return true;
}
但是显示的结果要摸是0要么是NULL
st=cql.executeQuery(sql);
while(st.next()){
gb.setGoodsname(st.getString("goodsname"));
gb.setGoodsname(st.getString("unit"));
gb.setGoodsname(st.getString("introduction"));
gb.setGoodsname(st.getString("company"));
gb.setGoodsname(st.getString("price"));
gb.setGoodsname(st.getString("total"));
al.add(gb);
}
} catch(SQLException e){
System.out.println("the sql error:"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
return al;
}
}
页面SCOPE我用的是REQUEST啊
<% int i=0;
int a;
int j=0;
ArrayList al=new ArrayList();
al=lookup.gethash();
Object ia[]=al.toArray();
a=ia.length; %>
function lookup(){
var index=<%=a%>;
var n=0;
document.write("<table width=500 height=500 border=1 align=center><tr>");
document.write("<th>商品名称</th><th>价格</th><th>计量单位</th><th>库存</th><th>产品介绍</th><th>生产厂家</th><tr>");
for(n=0;n<index;n++)
{
document.write("<td><%=gb.getGoodsname()%></td><td colspan=1><%=gb.getPrice()%></td><td><%=gb.getUnit()%></td><td><%=gb.getTotal()%></td><td colspan=1><%=gb.getIntroduction()%></td><td><%=gb.getCompany()%></td></table>");
}
return true;
}
但是显示的结果要摸是0要么是NULL
java Bean 同时也是一个JAVA类 你可以像调用其它类一样调用呀
<%
ResultSet set=Bean.getResultSet();
%>
ResultSet set=Bean.getResultSet();
%>你的意思是我的JAVA程序不用从后台返回结果集
直接用上面的语句就可以从BEAN里获取数据了
但是D:\tomcat4.1\work\Standalone\localhost\examples\lookgoods_jsp.java:79: cannot resolve symbol
symbol : method getResultSet ()
location: class Bean.GoodsBean
ResultSet st=gb.getResultSet();