Your SlideShare is downloading. ×
0
Spring MVC
Introduction




               Spring MVC
peter.maas@finalist.com ☄ maas-frensch.com/peter/




Peter Maas ~ Works at Finalist IT
Group. 70% Developer, 20%
Architect...
Introduction to Spring MVC & Web Flow




                      Spring MVC
Spring




Spring ~ A Layered Java/JEE
application framework. The most
complete lightweight container,
providing centraliz...
Why Spring (I)


Key reasons

To provide a non-invasive programming model. As far as
possible, application code should be ...
Why Spring (II)




Spring MVC
Spring basics




<bean id=quot;myRespositoryquot; class=quot;com.finalist.MyRepositoryImplquot;/>
<bean id=quot;myServiceq...
Spring basics (II)




<bean id=quot;myRespositoryquot; class=quot;com.finalist.MyRepositoryImplquot;/>
<bean id=quot;mySer...
Demo I




Demo I ~ Basics of Spring




                            Spring MVC
Typical SpringMVC Architecture


Spring MVC territory




                                                      Business l...
MVC




                   Controller


        request



                                Model


Actor
        response
...
Controller




Controller ~ Controllers interpret
user input and transform such input
into a sensible model which will be
...
Controller Interface




                                                           If you find yourself
                  ...
Controllers



                                       «interface»
                                                        ...
Model




Model ~ The domain-specific
representation of the information on
which the application operates.
List<SearchResul...
View




View ~ Renders the model into a
for m suitable for interaction,
typically a user interface element.
Multiple view...
Views
                        view




                                         RedirectView           JstlView
AbstractEx...
Handlers




Handlers ~ map incoming web requests to appropriate handlers.
<bean id=quot;handlerMappingquot;
    class=quo...
Demo II




Demo II ~ Putting it all to work,
making a simple quot;Hello Worldquot;
Spring MVC application.




          ...
Demo II ~ Classpath essentials

spring-webmvc.jar
commons-logging.jar
logkit.jar
spring-beans.jar
spring-context.jar
aopal...
More to come ~ Complex forms,
Binding, Validation, Interceptors,
Inter nationalisation, Webflow,
Ajax ...




             ...
internet




                                                   Firewall &
                                               ...
Upcoming SlideShare
Loading in...5
×

Spring MVC introduction HVA

8,593

Published on

Quick introduction to Spring MVC for the HvA

Published in: Technology, Education
2 Comments
13 Likes
Statistics
Notes
No Downloads
Views
Total Views
8,593
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
651
Comments
2
Likes
13
Embeds 0
No embeds

No notes for slide

Transcript of "Spring MVC introduction HVA"

  1. 1. Spring MVC Introduction Spring MVC
  2. 2. peter.maas@finalist.com ☄ maas-frensch.com/peter/ Peter Maas ~ Works at Finalist IT Group. 70% Developer, 20% Architect and 10% CTO Board. Techniques used daily include Java/ JEE, Spring, Hiber nate, JSP. Passionate about scripting language for the JVM like Groovy and JRuby. Spring MVC
  3. 3. Introduction to Spring MVC & Web Flow Spring MVC
  4. 4. Spring Spring ~ A Layered Java/JEE application framework. The most complete lightweight container, providing centralized, automated configuration and wiring of your application objects. Spring MVC
  5. 5. 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. Spring MVC
  6. 6. Why Spring (II) Spring MVC
  7. 7. Spring basics <bean id=quot;myRespositoryquot; class=quot;com.finalist.MyRepositoryImplquot;/> <bean id=quot;myServicequot; class=quot;com.finalist.MyServiceImplquot;> <property name=quot;maxResultsquot; value=quot;10quot;/> <property name=quot;myRespositoryquot; ref=quot;myRespositoryquot;/> </bean> Equals myRepository = new MyRepositoryImpl(); myService = new MyServiceImpl(); myService.setMyRepository(myRepository); myService.setMaxResults(10); Spring MVC
  8. 8. Spring basics (II) <bean id=quot;myRespositoryquot; class=quot;com.finalist.MyRepositoryImplquot;/> <bean id=quot;myServicequot; class=quot;com.finalist.MyServiceImplquot;> <constructor-arg index=quot;0quot; value=quot;10quot;/> <constructor-arg index=quot;1quot; ref=quot;myRespositoryquot;/> </bean> Equals myRepository = new MyRepositoryImpl(); myService = new MyServiceImpl(10, myRepository); Spring MVC
  9. 9. Demo I Demo I ~ Basics of Spring Spring MVC
  10. 10. Typical SpringMVC Architecture Spring MVC territory Business logic User Interface Web Domain Connections to exernal Model systems (database, Services webservices) Integration Spring MVC
  11. 11. MVC Controller request Model Actor response View Spring MVC
  12. 12. Controller Controller ~ Controllers interpret user input and transform such input into a sensible model which will be represented to the user by the view. Spring MVC
  13. 13. Controller Interface If you find yourself implementing the controller interface you're probable doing public interface Controller { stuff the hard way! /** * Process the request and return a * ModelAndView object which the DispatcherServlet * will render. */ ModelAndView handleRequest( HttpServletRequest request, HttpServletResponse response) throws Exception; } Spring MVC
  14. 14. Controllers «interface» UrlFilenameViewController Controller ParameterizableViewController MultiActionController AbstractController BaseCommandController AbstractCommandController SimpleFormController AbstractFormController AbstractWizardFormController Spring MVC
  15. 15. Model Model ~ The domain-specific representation of the information on which the application operates. List<SearchResult> results = new ArrayList<SearchResult>(); model.addObject(quot;searchResultsquot;, results); List<SearchResult> r = (List<SearchResult>)model.get(quot;searchResultsquot;); Spring MVC
  16. 16. View View ~ Renders the model into a for m suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. Spring MVC
  17. 17. Views view RedirectView JstlView AbstractExcelView AbstractView InternalResourceView TilesView TilesJstlView AbstractPDFView AbstractUrlB asedView ... AbstractJExcelView AbstractJasperReportsView ... AbstractExcelView AbstractTemplateView AbstractXsltView Spring MVC
  18. 18. Handlers Handlers ~ map incoming web requests to appropriate handlers. <bean id=quot;handlerMappingquot; class=quot;org.springframework.web.servlet.handler.BeanNameUrlHandlerMappingquot; /> or <bean id=quot;urlMappingquot; class=quot;org.springframework.web.servlet.handler.SimpleUrlHandlerMappingquot;> <property name=quot;urlMapquot;> <map> <entry key=quot;/helloquot; value-ref=quot;helloworldControllerquot; /> </map> </property> </bean> Spring MVC
  19. 19. Demo II Demo II ~ Putting it all to work, making a simple quot;Hello Worldquot; Spring MVC application. Spring MVC
  20. 20. Demo II ~ Classpath essentials spring-webmvc.jar commons-logging.jar logkit.jar spring-beans.jar spring-context.jar aopalliance.jar spring-core.jar spring-support.jar spring-web.jar log4j.jar Spring MVC
  21. 21. More to come ~ Complex forms, Binding, Validation, Interceptors, Inter nationalisation, Webflow, Ajax ... Spring MVC
  22. 22. internet Firewall & Loadbalancer Multicast / RMI Cache replication Application servers (web) Backoffice & cron jobs REST (https) internet REST (https) signon.vpro.nl SOAP (http) belbios XML JDBC JDBC LDAP Database cluster Active NFS 3rd party systems Directory (NEBO/DONNA) MMBase scp Spring MVC
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×