2023. 12. 31. 11:42ㆍSpringBoot+JPA
[SpringBoot 구조] Entity 설명 및 정의 / 어노테이션
더보기 [목차] - Entity 정의 - Entity 구조 - Entity에 사용되는 어노테이션 종류 Entity 정의 자바 어플리케이션에서 관계형 데이터베이스의 데이터를 객체로 표현하는 데 사용 엔터티 객체를 통해 데
dalhyehye.tistory.com
[SpringBoot 구조] DTO 설명 및 정의 / 어노테이션
DTO 정의 클라이언트와 서버 간의 데이터 전송을 위해 사용되는 객체 데이터베이스에서 가져온 데이터나 서비스 간의 통신에 필요한 데이터를 담고 있는 객체 교환할 자료에 따라 여러 개로 구
dalhyehye.tistory.com
[SpringBoot 구조] Repository 설명 및 정의 / 어노테이션
[SpringBoot 구조] Entity 설명 및 정의 / 어노테이션 더보기 [목차] - Entity 정의 - Entity 구조 - Entity에 사용되는 어노테이션 종류 Entity 정의 자바 어플리케이션에서 관계형 데이터베이스의 데이터를 객
dalhyehye.tistory.com
[SpringBoot 구조] Service 설명 및 정의 / 어노테이션
[SpringBoot 구조] Entity 설명 및 정의 / 어노테이션 더보기 [목차] - Entity 정의 - Entity 구조 - Entity에 사용되는 어노테이션 종류 Entity 정의 자바 어플리케이션에서 관계형 데이터베이스의 데이터를 객
dalhyehye.tistory.com
Controller 정의
웹 애플리케이션의 HTTP 요청을 처리
클라이언트와 서버 간의 상호작용을 담당
view영역에 파일과 Service영역에 메소드를 연결
서버 요청시 가장 먼저 처리되는 부분
사용자의 요청을 받아서 비즈니스 로직을 호출
그 결과를 템플릿 엔진이나 JSON 형태로 렌더링하여 클라이언트에게 응답
Controller 구조 및 작성 방법
@Controller
@RequiredArgsConstructor
public class ProductController {
private final ProductService productService;
//개별조회
@GetMapping("/productdetail")
public String productDetail (Integer productId, Model model) throws Exception {
ProductDTO productDTO = productService.findOne(productId);
model.addAttribute("productDTO", productDTO);
return "/product/detail";
}
}
Controller 사용 어노테이션
@Controller | 해당 클래스를 컨트롤러로 선언 |
요청방식(매핑Mapping)
@GetMapping | 페이지 연결, 삭제, 간단한 변수로 처리 |
@PostMapping | 삽입, 수정, 삭제, form으로 처리 |
@PutMapping | 수정, form으로 처리 |
@DeleteMapping | 삭제, 변수 또는 Form으로 처리 |
@RequestParam | 클라이언트가 전달한 파라미터를 메서드의 매개변수로 받아 처리 |
모델(Model) 객체 사용
컨트롤러에서는 모델 객체를 사용하여 뷰로 데이터를 전달
Model(요청 페이지의 정보) model(Model 생성 → 변수)
model.addAttribute(”전달할 변수명”, 값)
[SpringBoot] Model 인터페이스 / 데이터전달 / 사용방법
Model 컨트롤러에서 뷰로 데이터를 전달하는 데 사용되는 인터페이스 뷰에 데이터를 전달할 때 사용 컨트롤러에서 처리된 데이터를 뷰에 적용하여 사용자에게 적절한 응답을 생성하는 데 도움 Co
dalhyehye.tistory.com
'SpringBoot+JPA' 카테고리의 다른 글
[JPA] jpa정의 / 사용이유 / 작성방법 (0) | 2023.12.31 |
---|---|
[SpringBoot] Model 인터페이스 / 데이터전달 / 사용방법 (1) | 2023.12.31 |
[SpringBoot 구조] Service 설명 및 정의 / 어노테이션 (0) | 2023.12.31 |
[SpringBoot 구조] Repository 설명 및 정의 / 어노테이션 (0) | 2023.12.31 |
[SpringBoot 구조] DTO 설명 및 정의 / 어노테이션 (0) | 2023.12.31 |