product.jsp
<%
List all = null ;
all = (List)request.getAttribute("all") ;
%>Productservlet
try
{
request.setAttribute("all",Daofactory.getProductdaoimp().queryAll()) ;
}org.apache.jasper.JasperException: Exception in JSP: /product.jsp:2825: <th>删除</th>
26: </tr>
27: <%
28: Iterator iter = all.iterator() ;
29: while(iter.hasNext())
30: {
31: Product p = (Product)iter.next() ;
<%
List all = null ;
all = (List)request.getAttribute("all") ;
%>Productservlet
try
{
request.setAttribute("all",Daofactory.getProductdaoimp().queryAll()) ;
}org.apache.jasper.JasperException: Exception in JSP: /product.jsp:2825: <th>删除</th>
26: </tr>
27: <%
28: Iterator iter = all.iterator() ;
29: while(iter.hasNext())
30: {
31: Product p = (Product)iter.next() ;
解决方案 »
- 高手请进,老问题,一直没解决.
- 想做个开源的java cms
- jsp jdbc 的问题弄一天了 快疯了 求救
- 用jsp读取复选框实例?
- 请教jsp中的函数
- 怎样先返回页面在提示?
- 请教open(url,"loader"),open(url,"_blank")参数的含义,
- 各位大侠帮忙解决一下JSP与MYSQL连接的问题
- 数据库连接池中,找不到类!org.apache.commons.dbcp.BasicDataSourceFactory!
- 数据库中正常,在JSP中显示好象为十六进制数,帮忙解决
- struts 1.2和hibernate 3.2配置
- dao中的一个关于数据库的问题,包含迭代器,急!请大家多费心
把all打出来看看是不是空值null
要去你别人代码里找了这里是找不出来了的
你的这个工厂类中的方法的实现,是不是查询到数据?
最好输出一下
<%
List all = null ;
all = (List)request.getAttribute("all") ;
%> Productservlet
try
{
request.setAttribute("all",Daofactory.getProductdaoimp().queryAll()) ;
} Productdaoimp
public List queryAll()
{
List all=new ArrayList();
String sql = "SELECT * FROM categories" ;
try
{
Connection conn = pool.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery() ;
while(rs.next())
{
Product p= new Product() ;
p.setProductid(rs.getInt(1)) ;
p.setCategoryid(rs.getInt(2));
p.setName(rs.getString(3));
p.setDescription(rs.getString(4));
p.setPrice(rs.getFloat(5));
all.add(p) ;
}
rs.close() ;
pstmt.close() ;
conn.close() ;
}
catch (Exception e)
{
e.printStackTrace();
}
return all ;
}org.apache.jasper.JasperException: Exception in JSP: /product.jsp:28 25: <th>删除 </th>
26: </tr>
27: <%
28: Iterator iter = all.iterator() ;
29: while(iter.hasNext())
30:…
我是初学者,请大家多多指教,请说的具体点,谢谢!
从代码上看好像没有问题,怀疑是不是程序没有运行到这段代码,把它前面加上一句输出看看得到的listList temp = Daofactory.getProductdaoimp().queryAll();
System.out.println("All size:" + temp.size());
request.setAttribute("all", temp) ;
没有输出的话说明是程序根本就没有运行到查询数据库的这段代码,所以页面上all = (List)request.getAttribute("all") ; 拿到的是空值null。你设个断点跟踪一下程序的流程,看看是不是没有走到查询数据哪一步。