I am trying to create a simple application in which a user can add an image. The name of the image and the path of the folder where I am storing the image but when trying to retrieve it. It shows "Not allowed to load local resource: file:///H:/Projectpictures/BrowserForDataTables.PNG" Error on browser console. please have a look and let me know what is it I am doing wrong here. Here is my code.
This is the DAOImplementation code for retrive:
@Override
@Transactional
public List<pictureModal> allImages() {
Session currentSession = sessionFactory.getCurrentSession();
Query<pictureModal> query = currentSession.createQuery("from pictureModal");
List<pictureModal> pictues= query.getResultList();
return pictures;
}
This is Controller code for getimages:
@RequestMapping("/seeAllImages")
public String getAllImage(Model theModal) {
List<pictureModal> myPictures= pictureServ.allImages();
theModal.addAttribute("myPicture",myPictures);
return "ImagePage";
}
And here is the code for JSP file:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Pictures will display here</title>
</head>
<body>
<h2>Display Pictures </h2>
<table border="1">
<thead>
<tr>
<th>Picture Name</th>
<th>Picture</th>
</tr>
</thead>
<c:forEach var="tempPic" items="${myPicture}">
<tbody>
<tr>
<td>${tempPic.name}</td>
<td><img src="${tempPic.path}"></td>
</tr>
</tbody>
</c:forEach>
</table>
</body>
</html>