13. Spring Boot update Debugging

김미숙's avatar
Jul 15, 2025
13. Spring Boot update Debugging
‼️

View → Controller → Service → Repository

1. Form GET

❓ form tag에 method가 없으면?
notion image
notion image
notion image
notion image
notion image
❗ 기본적으로 form tag의 method는 “GET” 요청
→ update는 “POST” 요청이므로 form tag에 method=post를 써줘야 한다
 

2. input tag name 값

❓ input tag의 name 값이 아예 없거나 오타가 있다면?
notion image
notion image
notion image
notion image
notion image
❗ URL Parameter 이름이 “price”일 때 method에서 price 변수에 받는데, input tag의 name값은 없으므로 오류가 발생한다
 

3. RequestParam 값

💡
Spring 프레임워크에서 요청 파라미터를 컨트롤러 메서드의 매개변수로 바인딩할 때 사용하는 어노테이션입니다. 주로 @GetMapping 또는 @PostMapping과 함께 사용됩니다.

🛠 정리

  • @RequestParam은 쿼리 스트링 또는 폼 데이터에서 값을 받아올 때 사용.
  • required = false로 설정하면 파라미터가 없어도 오류 발생하지 않음.
  • defaultValue를 사용하면 기본값 지정 가능.
  • List<T> 타입으로 여러 값을 받을 수도 있음.

📌 @RequestParam vs @PathVariable

어노테이션
데이터 위치
예제 URL
메서드 예제
@RequestParam
쿼리 스트링
/user?name=John
@RequestParam String name
@PathVariable
URL 경로 변수
/user/John
@PathVariable String name
❓ 값에 오타가 있으면?
notion image
notion image
❗ URL Parameter 이름이 “prlce”일 때 method에서 price 변수에 받는데, input tag의 name값은 “price”이므로 오류가 발생한다
 
❓ RequestParam의 값이 아예 없으면?
notion image
notion image
❗ price 변수에 받을 URL Parameter가 없어서 오류 발생
 
 

4. Transactoinal

notion image
notion image
notion image
Share article