introduction to springmvc

Upload: tirumal3883

Post on 30-May-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Introduction to Springmvc

    1/22

    Spring MVC

    Spring MVC

    Introduction

  • 8/14/2019 Introduction to Springmvc

    2/22

    Spring MVC

    Peter Maas ~ Works at Finalist IT

    Group. 70% Developer, 20%

    Architect and 10% CTO Board.

    Techniques used daily include Java/ JEE, Spring, Hibernate, JSP.

    Passionate about scripting language

    for the JVM like Groovy and JRuby.

    [email protected] maas-frensch.com/peter/

  • 8/14/2019 Introduction to Springmvc

    3/22

    Spring MVC

    Introduction to Spring MVC & Web Flow

  • 8/14/2019 Introduction to Springmvc

    4/22

    Spring MVC

    Spring ~ A Layered Java/JEE

    application framework. The most

    complete lightweight container,

    providing centralized, automated

    configuration and wiring of your

    application objects.

    Spring

  • 8/14/2019 Introduction to Springmvc

    5/22

    Spring MVC

    Why Spring (I)

    Key reasons

    To provide a non-invasive programming model. As far as

    possible, application code should be decoupled from the

    framework.

    To provide a superior solution to in-house infrastructure,

    so that developers can focus on delivering business value

    rather than solving generic problems.

    To make developing enterprise applications as simple as

    possible, but enhancing, rather than sacrificing, power.

  • 8/14/2019 Introduction to Springmvc

    6/22

    Spring MVC

    Why Spring (II)

  • 8/14/2019 Introduction to Springmvc

    7/22

    Spring MVC

    Equals

    myRepository = new MyRepositoryImpl();

    myService = new MyServiceImpl();

    myService.setMyRepository(myRepository);

    myService.setMaxResults(10);

    Spring basics

  • 8/14/2019 Introduction to Springmvc

    8/22

    Spring MVC

    Equals

    myRepository = new MyRepositoryImpl();

    myService = new MyServiceImpl(10, myRepository);

    Spring basics (II)

  • 8/14/2019 Introduction to Springmvc

    9/22

    Spring MVC

    Demo I~ Basics of Spring

    Demo I

  • 8/14/2019 Introduction to Springmvc

    10/22

    Spring MVC

    Integration

    Services

    Web

    Domain

    Model

    User Interface

    Typical SpringMVC Architecture

    Spring MVC territory

    Business logic

    Connections to exernalsystems (database,

    webservices)

  • 8/14/2019 Introduction to Springmvc

    11/22

    Spring MVC

    MVC

    Actor

    View

    Model

    Controller

    request

    response

  • 8/14/2019 Introduction to Springmvc

    12/22

    Spring MVC

    Controller ~ Controllers interpret

    user input and transform such input

    into a sensible model which will be

    represented to the user by the view.

    Controller

  • 8/14/2019 Introduction to Springmvc

    13/22

    Spring MVC

    publicinterface Controller {

    /**

    * Process the request and return a* ModelAndView object which the DispatcherServlet* will render.*/ModelAndView handleRequest(

    HttpServletRequest request,

    HttpServletResponse response) throws Exception;

    }

    If you find yourselfimplementing the

    controller interfaceyou're probable doing

    stuff the hard way!

    Controller Interface

  • 8/14/2019 Introduction to Springmvc

    14/22

    Spring MVC

    interfaceController

    AbstractController

    SimpleFormController AbstractWizardFormController

    ParameterizableViewController

    BaseCommandController

    AbstractFormController

    AbstractCommandController

    MultiActionController

    UrlFilenameViewController

    Controllers

  • 8/14/2019 Introduction to Springmvc

    15/22

    Spring MVC

    Model

    Model~ The domain-specific

    representation of the information on

    which the application operates.

    List results =new ArrayList();

    model.addObject("searchResults", results);

    List r =(List)model.get("searchResults");

  • 8/14/2019 Introduction to Springmvc

    16/22

    Spring MVC

    View

    View ~ Renders the model into a

    form suitable for interaction,

    typically a user interface element.Multiple views can exist for a single

    model for different purposes.

  • 8/14/2019 Introduction to Springmvc

    17/22

    Spring MVC

    view

    RedirectView

    InternalResourceView

    AbstractJasperReportsView

    AbstractTemplateView

    AbstractView

    AbstractExcelView

    AbstractUrlBasedView

    AbstractExcelView

    AbstractPDFView

    AbstractXsltView

    AbstractJExcelView ...

    ...

    JstlView

    TilesView

    Views

    TilesJstlView

  • 8/14/2019 Introduction to Springmvc

    18/22

    Spring MVC

    Handlers ~ map incoming web requests to appropriate handlers.

    or

    Handlers

  • 8/14/2019 Introduction to Springmvc

    19/22

    Spring MVC

    Demo II ~ Putting it all to work,

    making a simple "Hello World"Spring MVC application.

    Demo II

  • 8/14/2019 Introduction to Springmvc

    20/22

    Spring MVC

    Demo II~ Classpath essentials

    spring-webmvc.jar

    commons-logging.jar

    logkit.jar

    spring-beans.jar

    spring-context.jaraopalliance.jar

    spring-core.jar

    spring-support.jar

    spring-web.jar

    log4j.jar

  • 8/14/2019 Introduction to Springmvc

    21/22

    Spring MVC

    More to come ~ Complex forms,

    Binding, Validation, Interceptors,

    Internationalisation, Webflow,Ajax ...

    internet

  • 8/14/2019 Introduction to Springmvc

    22/22

    Spring MVC

    Multicast / RMI Cache replication

    Application servers (web)

    Database cluster

    Backoffice &cron jobs

    internet

    JDBC JDBC

    internet

    signon.vpro.nl

    REST (https)

    REST (https)

    belbios

    Firewall &Loadbalancer

    ActiveDirectory

    LDAP

    MMBase

    SOAP (http)

    NFS

    XML

    3rd party systems(NEBO/DONNA)

    scp