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。