1> 스프링과 파일 업로드 https://github.com/euijooning/inflearn_File_Upload GitHub - euijooning/inflearn_File_Upload: 파일 업로드를 실습하기 위한 예제 파일입니다. 파일 업로드를 실습하기 위한 예제 파일입니다. Contribute to euijooning/inflearn_File_Upload development by creating an account on GitHub. github.com 2> 스프링 핵심 원리 관련 주제 > 📮주문과 할인 도메인 개발 📮Spring Container, Spring Bean 📮Singleton Container 📮Component Scan 📮Dependency Injection 📮Bean Lif..
재구조화 실시 클래스 Item.java @Data @NoArgsConstructor public class Item { private Long id; private String itemName; private Integer price; private Integer quantity; public Item(String itemName, Integer price, Integer quantity) { this.itemName = itemName; this.price = price; this.quantity = quantity; } } ItemRepository.java @Repository // 인터페이스가 아니므로 붙인 듯. 안에 @Component 있음 public class ItemRepository { ..
타임리프 스프링 통합 타임리프는 크게 2가지 메뉴얼을 제공한다. 기본 메뉴얼 : https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html Tutorial: Using Thymeleaf 1 Introducing Thymeleaf 1.1 What is Thymeleaf? Thymeleaf is a modern server-side Java template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text. The main goal of Thymeleaf is to provide a www.th..
스프링과 파일 업로드 스프링은 MultipartFile 이라는 인터페이스로 멀티파트 파일을 매우 편리하게 지원한다. SpringUploadController @Slf4j @Controller @RequestMapping("/spring") // 이 컨트롤러의 요청 매핑(prefix)을 "/spring"으로 지정합니다. public class SpringUploadController { @Value("${file.dir}") // 스프링의 프로퍼티에서 값을 읽어와서 변수에 주입. private String fileDir; // 파일을 저장할 디렉토리 경로를 저장하는 변수. @GetMapping("/upload") public String newFile() { return "upload-form"; } @P..
서블릿과 파일 업로드2 서블릿이 제공하는 Part 에 대해 알아보고 실제 파일도 서버에 업로드 해보자. 1. 먼저 파일을 업로드를 하려면 실제 파일이 저장되는 경로가 필요하다. - 해당 경로에 실제 폴더를 만들어두자. - 그리고 다음에 만들어진 경로를 입력해두자. 나의 저장 경로 C:\Inflearn_Spring\file application.properties 에 파일 업로드 경로 설정 예시 내 application.properties file.dir=C:/Inflearn_Spring/file 주의 cf. 2번의 경우 요즘은 굳이 안 넣어도 되나봄. 특히 windows는 \\ 로 구분을 했으나, 요즘에는 / 로 써도 스프링이 전부 호환해줌. ServletUploadControllerV2 @Slf4j @..
템플릿 레이아웃 01 템플릿 레이아웃 이전에는 일부 코드 조각을 가지고와서 사용했다면, 이번에는 개념을 더 확장해서 코드 조각을 레이아웃에 넘겨서 사용하는 방법에 대해서 알아보자. 예를 들어서 Thymeleaf 템플릿에서 공통 헤더 부분을 정의하는 템플릿 프래그먼트다. 이 템플릿은 common_header라는 이름을 가지며, title과 links라는 두 개의 파라미터를 받는다. title 파라미터는 웹 페이지의 타이틀을 동적으로 설정한다. 이를 위해 태그를 사용. 공통 CSS 스타일 시트, favicon, JavaScript 스크립트는 모든 웹 페이지에서 공유되며, th:href와 th:src를 사용하여 경로를 지정한다. links 파라미터는 추가적인 링크를 동적으로 삽입한다. th:block과 th:..