Hỏi & Đáp
그냥 단순히 컬럼에 article_id를 넣어줌으로써 테이블간에도 연관관계가 맺어졌다고 볼 수 있나? 라는 의문이 들어서 여쭤본거긴 합니다. 강사님 설명 들으니 이해가 되네요 comment 테이블에서 article_id를 참조함으로써 연관관계가 맺어진걸 알 수 있는데, 그럼 혹시 제약조건을 걸지 않는 이유가 뭘까요? 배우는 입장으로서 학습할 때 제약조건을 걸어야 참조 무결성을 유지한다고 알고있는데 실무에서는 제약조건없이 참조만 하는 이유를 알고싶습니다
2025-02-03T12:33:57.011Z
Lượt thích
0
Số bình luận
3
Lượt xem
301
Hỏi & Đáp
@PostMapping("/upload") public String saveFile2(@RequestParam String itemName, @RequestParam MultipartFile file, HttpServletRequest request) throws IOException { String mainDir = System.getProperty("user.dir") + fileMainDir; Path mainDirPath = Paths.get(mainDir); if(!Files.exists(mainDirPath)) Files.createDirectories(mainDirPath); Path path = Paths.get(mainDir, file.getOriginalFilename()); file.transferTo(path.toFile()); return "upload-form"; } } fileMainDir은 application 설정파일에서 지정한 경로 변수이고, System.getProperty("user.dir")함수를 사용하면 현재 프로젝트가 실행중인 디렉토리의 절대 경로를 찾아내서 반환해준다고 하네요. 저는 이런방식으로 해결했는데 혹시 다른방식이나 베스트 프랙티스가 있을까요??
2024-04-13T07:06:13.691Z
Lượt thích
0
Số bình luận
2
Lượt xem
317