MVC 패턴과 Spring

  • View
    101

  • Download
    8

Embed Size (px)

DESCRIPTION

MVC 패턴과 Spring. MVC. 모델 1. MVC. 모델 2 - MVC. MVC. Controller( 또는 Action). 사용자 입력 데이터 추출 입력 데이터에 대한 유효성 체크 (Java Script 를 이용할 경우 JSP(View) 에서도 가능 ) 입력 데이터를 비즈니스 Layer 로 전달하기 위한 변환 작업 비즈니스 Layer 와 Interface 비즈니스 Layer 에서 발생한 에러 처리 비즈니스 Layer 에서 반환된 데이터를 View 에 전달. MVC. - PowerPoint PPT Presentation

Text of MVC 패턴과 Spring

  • MVC Spring

  • MVC 1

  • MVC 2 - MVC

  • MVCController( Action)

    (Java Script JSP(View) )

    Layer

    Layer Interface

    Layer

    Layer View

  • MVCModel ?

  • MVCModelDomain Model=

  • MVCModelDomain Model=+Business Obj+DAO

  • MVCBROWSERJSP 11. Request2. Response

  • MVCBROWSER(Controller)Servlet(View)JSP 21. Request2. Response3. Request4. Response

  • Spring Framework - MVC

  • Spring Framework - MVC

  • Spring Framework - MVC2

  • Spring MVCDispatcherServlet12356HandlerMappingControllerModelAndView4ViewResolverView

  • Spring MVC

  • Spring MVC - Controller 1HelloWorldController

  • Spring MVCDispatcherServlet/index.html12356BeanNameUrlHandlerMappingMyUrlFilenameViewControllerModelAndViewindex4InternalResourceViewResolver/WEB-INF/jsp/index.jsp

  • Spring MVC - Controller

  • Spring MVC - ControllerUrlFilenameViewController=No Model

  • Spring MVC - ControllerMultiActionController=DispatchAction of StrutsAction of Webwork

  • Spring MVC - ControllerListActionBROWSERList.doInsertActionInsert.doUpdateActionUpdate.doViewActionView.doDeleteActionDelete.doURL : Action=1 : 1

  • Spring MVC - Controller URL Action(Controller) .

    Action(Controller) Action

    URL .

    Action(Controller) .

    .

  • Spring MVC - ControllerSampleActionBROWSERList.doInsert.doUpdate.doView.doDelete.doURL : Action=N : 1

  • Spring MVC - Controller 2MultiHelloWorldController

  • Spring MVC - Controller

  • Spring MVC - ControllerSimpleFormController

  • Spring MVC - BeanNameHandlerMapping

  • Spring MVC - SimpleUrlHandlerMapping

  • Spring MVC - SimpleUrlHandlerMapping

    loginFormController

    boardController

  • Spring MVC - Interceptor

    loginFormController

    boardController

    Spring MVC Interceptor

  • Spring MVC - ViewModelJSTLViewExcelViewPDFViewCSVViewHTML Excel PDF CSV

  • Spring MVC - ViewResolverModelInternalResource ViewResolverVelocity ViewResolverFreeMarker ViewResolverResourceBundleViewResolverJSPVelocityFreemarkerResourceBundle

  • Spring MVC - ViewResolverViewResolver Chain

    org.springframework.web.servlet.view.JstlView

    InternalResourceViewResolver Chain

  • Property EditorProperty Editor ?java.beans.PropertyEditor

  • Property Editor

    java.lang.String c:/test.txt en-GB http://www.springframework.org name=foo age=19 rob,jan,rod,jurgen,alef Hello World

  • Property Editorimport java.io.File;import java.net.URL;import java.util.Locale;import java.util.Properties;

    public class PropertyEditorBean {

    private Class cls;

    private File file;

    private URL url;

    private Locale locale;

    private Properties properties;

    private String[] strings;

    private byte[] bytes;

    }

  • Spring 2.0Convention over Configuration(CoC)

  • Spring 2.0Controller

    HelloWorldController => helloworld.do

    HelloWorldController.hello => helloworld/hello.do

  • Spring 2.0Model

    x.y.User => user

    java.util.HashMap => hashMap

    x.y.User[] => userList

    x.y.User java.util.ArrayList => userList

  • Spring 2.0View

    http://localhost:8080/helloworld.do => WEB-INF/jsp/helloworld.jsp

    http://localhost:8080/helloworld/hello.do => WEB-INF/jsp/helloworld/hello.jsp

  • Spring 2.0 3MultiHelloWorldControllerCoC

  • Spring

  • Spring

  • Spring

  • Spring

  • !! RequestDispatcher : http://wiki.javajigi.net/pages/viewpage.action?pageId=77

    Simplify Your Web App Development Using the Spring MVC Framework : http://www.devx.com/Java/Article/22134/1954?pf=true

    Property Editor Sample : http://www.java2s.com/Code/Java/Spring/PropertyEditorBean.htm