@@ -1,8 +1,17 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@@ -11,10 +20,37 @@ public class BookController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BookController.class);
|
||||
|
||||
//메인 페이지 이동
|
||||
@RequestMapping(value="/main", method = RequestMethod.GET)
|
||||
//메인 페이지 이동
|
||||
@RequestMapping(value="/main", method = RequestMethod.GET)
|
||||
public void mainPageGET() {
|
||||
logger.info("메인 페이지 진입");
|
||||
}
|
||||
|
||||
|
||||
/* 이미지 출력 */
|
||||
@GetMapping("/display")
|
||||
public ResponseEntity<byte[]> getImage(String fileName){
|
||||
|
||||
logger.info("getImage()........" + fileName);
|
||||
|
||||
File file = new File("c:\\upload\\" + fileName);
|
||||
|
||||
ResponseEntity<byte[]> result = null;
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders header = new HttpHeaders();
|
||||
|
||||
header.add("Content-type", Files.probeContentType(file.toPath()));
|
||||
|
||||
result = new ResponseEntity<>(FileCopyUtils.copyToByteArray(file), header, HttpStatus.OK);
|
||||
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@@ -17,4 +26,32 @@ public class BookController {
|
||||
logger.info("메인 페이지 진입");
|
||||
}
|
||||
|
||||
|
||||
/* 이미지 출력 */
|
||||
@GetMapping("/display")
|
||||
public ResponseEntity<byte[]> getImage(String fileName){
|
||||
|
||||
logger.info("getImage()........" + fileName);
|
||||
|
||||
File file = new File("c:\\upload\\" + fileName);
|
||||
|
||||
ResponseEntity<byte[]> result = null;
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders header = new HttpHeaders();
|
||||
|
||||
header.add("Content-type", Files.probeContentType(file.toPath()));
|
||||
|
||||
result = new ResponseEntity<>(FileCopyUtils.copyToByteArray(file), header, HttpStatus.OK);
|
||||
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user