编程时长:14h
代码行数:760行
发表博客篇数:3
所学知识点:
1.之前做WEB项目的时候显示内容一直用的当初学长的代码思路,将实体放进LIST集合,存进session,在JSP页面中用foreach来循环遍历出来,但是由于调整TOMCAT将jstl包搞坏,严重: Servlet.service() for servlet [jsp] in context with path [/图书管理系统] threw exception [The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application] with root cause
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application一直出现这样的报错,查询百度了很长一段时间还未解决,于是通过结对开发我学到一个新的显示内容的方法,
public ResultSet getAllRs(){ String sql="SELECT * from photo1 ORDER BY xuhao desc"; Connection conn = db.getConn(); ResultSet rs = null; try{ Statement state = conn.createStatement(); rs=state.executeQuery(sql); } catch(SQLException e){ e.printStackTrace(); } return rs; }
通过返回一个ResulSet结果集,在jsp页面直接输出结果
<% ResultSet rs=dao.getAllRs(); if(rs==null){ %> <tr align="center" valign="middle"><td colspan="4">没有记录显示!</td> </tr> <% } else{ if(rs.next()){ %> <tr align="center" valign="middle" height="22"> <td>222222</td> <td><%=rs.getString("id") %></td> <td><img src="upload\<%=rs.getString("name") %>" width="150px";height="100px"></td> </tr> <% }
原文地址:https://www.cnblogs.com/zjl-0217/p/11069803.html
时间: 2024-10-10 06:39:45