[Spring MVC] @ModelAttribute 와 Model @ModelAttribute : @ModelAttribute는 이전 포스팅에서 메소드의 아규먼트로 사용해서 파라미터들을 객체로 받을수 있었습니다. :@Controller 또는 @ControllerAdvice 를 사용한 클래스에서 모델 정보를 초기화 할때 사용합니다. :@RequsetMapping과 같이 사용하면 해당 메소드에서 리턴하는 객체를 모델에 넣어준다. => 객체를 리턴하면 어떤 페이지를 호출하게 되나? => 메소드 url과 같은 페이지를 default로 호출하게 된다. ( RequestToViewName Translator ) => @RequsetMapping 생략 가능 package com.example.demo; import java.time.LocalDateTime; import java... Spring/SpringMVC 6년 전
[Spring MVC] @ModelAttribute @ModelAttribute :여러곳에 있는 단순 타입 데이터를 복합 타입 객체로 받아오거나 해당 객체를 새로 만들때 사용할수 있다. 또한 생략 가능하다. - 어디서 받아 올수있나? : URI 패스, Request param , session등등 package com.example.demo; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframewor.. Spring/SpringMVC 6년 전