Back-End/Spring framework
Spring Path variable 사용 시 확장자
@deveely
2018. 9. 17. 22:05
반응형
1 2 3 4 5 6 | @RequestMapping("/temp/{filename}") public ResponseEntity<byte[]> tempView(@PathVariable String filename) throws IOException { logger.info("Return Temp image data"); logger.info(filename); return null; } | cs |
위와같이 매핑한 후
localhost:8080/content/temp/testFile.jpg
이런 경로로 주소를 날렸더니 에러가 발생했다.
문제는 로그에 찍힌 filename
.jpg는 사라진채 testFile만 들어와지는 것이었다.
1 | @RequestMapping("/temp/{filename:.+}") | cs |
리퀘스트 매핑을 위와같이 바꿔주니 확장자까지 잘 들어옴을 확인할 수 있었다.
반응형