경로는 찾으나 에러가뜹니다
412
작성자 없음
작성한 질문수 0
이미지는 엑박으로 표기.
->새탭에서 이미지열기시, 나오는경로-
http://localhost:8080/images/C:/Users/계정/springfile/images/c3a2eedd-4364-4f3f-a275-a800512e4949.png
파일다운로드 클릭시 경로와 에러페이지,
http://localhost:8080/attach/C:/Users/계정/springfile/uploadfiles/9aa381e7-6b8d-412a-bf86-28caf5b29010.pdf
으로 됩니다.
----
save시 컴퓨터 경로에 사진, 파일이 저장이되고
db에도 잘 저장됩니다..
코드
<img th:each="imageFile : ${board.attachFiles}"
th:if="${imageFile.attachType.toString().equals('IMAGE')}"
th:src="|/images/${imageFile.storeFileName}|" width="300" height="300" style="margin-right: 5px"/>
<a th:each="uploadFile : ${board.attachFiles}"
th:if="${uploadFile.attachType.toString().equals('FILE')}"
th:href="@{/attach/{filename}(filename=${uploadFile.storeFileName}, originName=${uploadFile.uploadFileName})}"
th:text="${uploadFile.uploadFileName}" style="margin-right: 5px"/><br/>
@ResponseBody
@GetMapping("/images/{filename}")
public Resource processImg(@PathVariable String filename) throws MalformedURLException {
return new UrlResource("file:" + fileStore.getFullPath(filename, AttachType.IMAGE));
@GetMapping("/attach/{filename}")
public ResponseEntity<Resource> processAttaches(@PathVariable String filename, @RequestParam String originName) throws MalformedURLException {
UrlResource resource = new UrlResource("file:" + fileStore.getFullPath(filename, AttachType.FILE));
String encodedUploadFileName = UriUtils.encode(originName, StandardCharsets.UTF_8);
String contentDisposition = "attachment; filename=\"" + encodedUploadFileName + "\"";
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
.body(resource);
}
답변 1
이미지 업로드와 db 트랜잭션 묶는법
0
43
1
Could not resolve org.springframework.boot:spring-boot-starter-validation:2.4.4
0
53
2
MessageSourceTest 코드
0
49
1
인터셉터 에러 설정
0
48
1
resolveArgument()메서드 질문
0
57
1
43강 검증1 에서 실패 로직 관련 질문있습니다.
0
58
2
타임리프 3.X 버전 rendering, serializer 에러 해결 방법
2
133
3
스프링 빈에 등록이 안되는거 같은데 어떻게 하면 좋을까요?ㅠㅠ
0
90
3
pdf 오타 문의
0
57
1
ItemUpdateForm 검증 관련 질문입니다.
0
49
1
22page 링크 주소 변경
0
59
2
특정 데이터와 파일을 함께 저장 시, 테이블 구조 질문
0
53
1
섹션3번 수업에 대한 질문입니다.
0
80
2
@Autowired 보다 더 좋은 방법이 어떤 걸까요?
0
85
2
타입컨버터 가 람다랑 비슷해 보이는데 저의 생각이 맞는지?.
0
66
1
자바스크립트 인라인에서 객체 직렬화 시 오류가 납니다
0
142
3
스프링부트 - 오류페이지2 에서 500.html 에서 쓰인 객체 질문
0
63
1
톰캣 에러 페이지가 안보입니다.
0
104
2
apiEceptionController에서 센드 에러 호출하면 안되는지?
0
81
1
세션 타임아웃시 쿠키 삭제 방법이 없나요?
0
118
2
ApiExceptionController 질문드립니다.
0
64
1
셀렉박스 챕터에서 option value에 ==배송 방식 선택== 이것을 넣은 이유가 궁금함, 이렇게 구상해도 되는지?
0
66
1
MemberRepository 필드의 fianl 선언 유무
0
85
2
혹시 index.html 에서는 fragment 사용이 안되는건가요
0
58
1





