일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
- JPA
- Java
- 자바의 정석
- 정처기
- Bean Validation
- 네트워크
- 프로그래머스
- 알고리즘
- ModelAttribute
- db
- 브루트 포스
- 검증
- 자바
- 운영체제
- 반복문
- 스프링
- OS
- programmers
- 메서드
- 스파르타코딩
- 면접
- 객체지향프로그래밍
- 코테
- 스프링MVC
- 자료구조
- 쿼리dsl
- 스프링 MVC
- 백준
- 웹개발
- 코딩테스트
- Today
- Total
목록Spring (16)
개발일지
목차 스프링이 제공하는 검증 오류 처리 방법을 알아볼텐데, 여기서 핵심은 ⭐BindingResult (BindingResult bindingResult 파라미터의 위치는 @ModelAttribute Item item 다음에 와야 함) 스프링이 제공하는 검증 오류 처리 방법 - BindingResult1 BindingResult 스프링이 제공하는 검증 오류를 보관하는 객체 (검증 오류가 발생하면 여기에 보관) BindingResult는 검증할 대상 바로 다음에 와야함 ex) @ModelAttribute Item item 바로 다음에 BindingResult가 오야함 BindingResult는 Model에 자동으로 포함됨 BindingResult에 검증 오류를 적용하는 방법 @ModelAttribute의 객..
목차 웹 서비스는 폼 입력시 오류가 발생하면, 고객이 입력한 데이터를 유지한 상태로 어떤 오류가 발생했는지 알려주어야 함 ⭐컨트롤러의 중요한 역할 중 하나는 HTTP 요청이 정상인지 검증하는 것 검증 직접 처리 - 개발 @PostMapping("/add") public String addItem(@ModelAttribute Item item, RedirectAttributes redirectAttributes, Model model) { //검증 오류 결과를 보관 Map errors = new HashMap(); // 검증 로직 if (!StringUtils.hasText(item.getItemName())){ // ItemName에 글자가 없으면, errors.put("itemName", "상품 이름은..
목차 상품 등록 처리 - @ModelAttribute 상품 등록폼에서 등록된 전달된 데이터로 실제 상품을 등록 처리하는 과정 상품 등록폼은 메시지 바디에 쿼리 파라미터 형시으로 전달하기에 @RequestParam 사용 @RequestParam @PostMapping("/add") public String addItemV1(@RequestParam String itemName, @RequestParam int price, @RequestParam Integer quantity, Model model) { Item item = new Item(); item.setItemName(itemName); item.setPrice(price); item.setQuantity(quantity); itemReposito..

목차 서비스 제공 흐름 상품 도메인 개발 Item - 상품 객체 package hello.itemservice.domain.item; import lombok.Data; @Data public class Item { private Long id; private String itemName; private Integer price; private Integer quantity; public Item() { } public Item(String itemName, Integer price, Integer quantity) { this.itemName = itemName; this.price = price; this.quantity = quantity; } } id를 생성자로 두지 않은 이유 : id는 DB에서..
목차 HTTP 요청 - 기본, 헤더 조회 package hello.springmvc.basic.request; import lombok.extern.slf4j.Slf4j; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import ..