2014. 8. 13. 17:46 Spring/Java
파일을 BLOB 형으로 DB에 저장하곤 한다-
이미지 역시 파일이니까 BLOB으로 저장하였는데,
출력하는 방법을 모르겠다-
생각보다 간단하다-
1. DB에서 BLOB형 이미지를 byte[]형으로 가져온다-
1 2 3 4 5 6 7 | @RequestMapping("/logoShowForStudent/{num}") public void imageView(HttpServletRequest req, HttpServletResponse res, @PathVariable("num") int num) throws IOException { res.setContentType("image/jpeg"); byte[] imagefile = service.showlogo(num); InputStream in1 = new ByteArrayInputStream(imagefile); IOUtils.copy(in1, res.getOutputStream()); } |
2. 어노테이션으로 지정한 request에 맞는 url을 이미지의 src로 준다-
1 | <img src ="/logoShowForStudent/${comp_detail.company_detail_seq }"></img> |
Excel Insert, poi (0) | 2014.08.12 |
---|---|
AOP 사용, 어노테이션 (0) | 2014.08.10 |
ppt to image/pdf 변환 (0) | 2014.08.10 |
간단한 암호화, MD5, SHA1 (0) | 2014.08.10 |
MyBatis 연결 설정 (0) | 2014.08.09 |