spring mvc final

Được đăng lên bởi Truong Lee
Số trang: 28 trang   |   Lượt xem: 1174 lần   |   Lượt tải: 0 lần
Spring Framework 3.0 MVC
Aaron Schram

University of Colorado PhD Student
Software Engineering
Previously employment
Mocapay, Inc (mobile payments)
Rally Software (agile tooling)
BEA (Weblogic Portal)
Lockheed Martin

What's Spring MVC?
A model-view-controller framework for Java
web application
Made to simplify the writing and testing of
Java web applications
Fully integrates with the Spring dependency
injection (Inversion of Control) framework
Open Source
Developed and maintained by Interface21,
recently purchased by VMWare

Project Goals
J2EE should be easier to use
It is best to program to interfaces, rather than
classes. Spring reduces the complexity cost of using
interfaces to zero.
JavaBeans offer a great way of configuring
OO design is more important than any
implementation technology, such as J2EE.
Checked exceptions are overused in Java. A platform
shouldn't force you to catch exceptions you're
unlikely to be able to recover from.
Testability is essential, and a platform such as Spring
should help make your code easier to test.

Why Use Spring MVC?
For most purposes you only have to define one
Servlet in web.xml
Capable of Convention over Configuration
Similar to Ruby on Rails or other popular web
frameworks that work with dynamic languages
Normal business objects can be used to back forms
No need to duplicate objects just to implement an
MVC's command object interface
Very flexible view resolvers
Can by used to map *.json, *.xml, *.atom, etc to
the same logic code in one controller and simply
output the type of data requested
Enforces good Software Engineering principles like

Let's Get Started!

Dispatcher Servlet
Used to handle all incoming requests and route
them through Spring
Uses customizable logic to determine which
controllers should handle which requests
Forwards all responses to through view handlers
to determine the correct views to route responses
Exposes all beans defined in Spring to controllers
for dependency injection

Dispatcher Servlet Architecture

Uses the Front Controller Design Pattern

Defining The Dispatcher Servlet

Defining a Dispatcher Servlet named "spring" that will intercept all
urls to this web application

Spring Configuration
By default Spring looks for a servletname servlet.xml file in /WEB-INF
For the previous example we would need to
create a file in /WEB-INF named spring-servlet.


spring-servlet.xml cont.

<mvc:annotation-driven /> tells Spring...
Spring Framework 3.0 MVC
Aaron Schram
spring mvc final - Trang 2
Để xem tài liệu đầy đủ. Xin vui lòng
spring mvc final - Người đăng: Truong Lee
5 Tài liệu rất hay! Được đăng lên bởi - 1 giờ trước Đúng là cái mình đang tìm. Rất hay và bổ ích. Cảm ơn bạn!
28 Vietnamese
spring mvc final 9 10 213