//controller is to upload file(file,image) to mysql database on phpmyadmin
@RequestMapping(value="/download/dsLogo")
public void getImage(@RequestParam("file") String fileName, HttpServletResponse response) throws IOException{
drivingSchoolService.findById(Integer.parseInt(fileName));
File file = new File(fileFolder1+fileName);
响应
etHeader("Content-Type", context.getMimeType(fileName));
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeaderresponse.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");
Files.copy(file.toPath(), response.getOutputStream());
}
header.jsp
<img src="${pageContext.request.contextPath}/file/download/dsLogo?file=${drivingSchool.dsLogo}"class="img-circle img-responsive pull-left"
alt="User Image">