
입력 폼 처리 지금부터 타임리프가 제공하는 입력 폼 기능을 적용해서 기존 프로젝트의 폼 코드를 타임리프가 지원하는 기능을 사용해서 효율적으로 개선해 나간다. 먼저, 미리 핵심요약 1. 2. 등록 폼 th:object 를 적용하려면 먼저 해당 오브젝트 정보를 넘겨주어야 한다. 등록 폼이기 때문에 데이터가 비어있는 빈 오브젝트를 만들어서 뷰에 전달한다. FormItemController 변경 @GetMapping("/add") public String addForm(Model model) { model.addAttribute("item", new Item()); return "form/addForm"; } form/addForm.html 변경 부분 그림으로 먼저 설명 addForm.html(전체) 상품 등록..

파일 업로드 & 다운로드 예제 요구사항 1) 상품을 관리 상품 이름 첨부파일 하나 이미지 파일 여러개 2) 첨부파일을 업로드 다운로드 할 수 있다. 3) 업로드한 이미지를 웹 브라우저에서 확인할 수 있다. Item - 상품 도메인 package inflearn.upload.domain; import lombok.Data; import java.util.List; @Data // 예제이므로 @Data public class Item { private Long id; private String itemName; private UploadFile attachFile; private List imageFiles; } ItemRepository - 상품 리포지토리 package inflearn.upload.dom..
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..