
본 샘플은 http링크 방식으로 이미지같은 것을 표시못하는
즉, WEB CONTEXT바깥에 존재하거나, 따로 파일 레파지토리에 있는 이미지 파일등을 화면에
뿌려줄때 사용하면 된다.
BLOB에 이미지가 들어있는 경우 해당 이미지를 뿌려줄때도 사용해도 되겟다 ㅎㅎ
try {
File f = new File("이미지 파일의 경로 및 파일명");
FileInputStream fis = new FileInputStream(f);
StringBuffer buf = new StringBuffer();
int c;
while ((c = fis.read()) != -1)
buf.append((char)c);
response.setContentType("image/jpeg");
response.getWriter().write(buf.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
위와 같이 간단히 구현이 가능하다. ㅎㅎ
No comments:
Post a Comment