1 图片已经上传,数据库也获得正确的图片地址
2 在页面上也可以查看到正确的图片地址
3 重新启动一下tomcat 图片就可以显示
这是什么问题
前端页面
<% response.setHeader("Pragma", "No-Cache"); response.setHeader("Cache-Control", "No-Cache"); response.setDateHeader("Expires", 0); BookDao bookDao = new BookDao(); List list = new ArrayList<>(); List item = new ArrayList(); list = bookDao.listBookInfo(); %> <% for (Books books : list ) { %> <%=books.getBookname() + "( 书号:" + books.getBookid() + ")"%> <%=books.getWriter()%> <%=books.getCbs()%> <%=books.getItems()%>
<% } %>
Dao
public List listBookInfo() { List list = new ArrayList(); try { String sql = "SELECT * FROM books WHERE isLend=1"; ps = conn.prepareStatement(sql); rs = ps.executeQuery(); while (rs.next()) { Books books = new Books(); books.setBookid(rs.getLong("bookId")); books.setBookname(rs.getString("bookName")); books.setCbs(rs.getString("cbs")); books.setWriter(rs.getString("writer")); books.setIslend(rs.getLong("isLend")); books.setItems(rs.getString("items")); books.setDate(rs.getTimestamp("date")); books.setImgPath(rs.getString("imgpath")); list.add(books); } } catch (SQLException e) { e.printStackTrace(); } return list; }
按照你的说法有一种可能性,你的图片还被存在内存中。
比如你的输出流是缓存的,但你的代码中既没有flush也没有close,然后重启导致了强制的flush。