프로그램/spring

Spring3 MVC 의 기본

mulderu 2011. 6. 26. 16:05

spring 의 시작은 보통 예제를 가지고 확장 하는 수준에서 시작하는 경우가 많고,
그렇게 하는게 별 무리가 없다.
보통 spring 책을 보면 장황하게 여러가지를 설명하고 있는데, spring mvc 의 기본은 아래의 페이지를 참고 하면 아주 좋을 듯 합니다.
일부 핵심 내용은 제가 이미지로 캡쳐해서 블로그에 직접 담았습니다.




Spring MVC 의 기본을 쉽게 알 수 있도록 도와 주는 예제... 

출처 : http://www.vaannila.com/spring/spring-mvc-tutorial-1.html

또한 자바개발자에게는 아주 유용한 리소스가 많이 있다
VaanNila : http://www.vaannila.com/index.html


Spring MVC

Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic and navigation logic. Models are responsible for encapsulating the application data. The Views render response to the user with the help of the model object . Controllers are responsible for receiving the request from the user and calling the back-end services.

The figure below shows the flow of request in the Spring MVC Framework.


 


When a request is sent to the Spring MVC Framework the following sequence of events happen.

  • The DispatcherServlet first receives the request.
  • The DispatcherServlet consults the HandlerMapping and invokes the Controller associated with the request.
  • The Controller process the request by calling the appropriate service methods and returns aModeAndView object to the DispatcherServlet. The ModeAndView object contains the model data and the view name.
  • The DispatcherServlet sends the view name to a ViewResolver to find the actual View to invoke.
  • Now the DispatcherServlet will pass the model object to the View to render the result.
  • The View with the help of the model data will render the result back to the user.

Spring MVC 의 핵심인 Controller Class Example