Title: Spring Web MVC
1Spring Web MVC
2Ievads
- Spring ir atklata koda Java/J2EE aplikaciju
ietvars - Viens no interesantakiem komponentiem ir Spring
Web MVC
3Web aplikaciju uzdevumi
- Svarigie uzdevumi, kuri ir jaatrisina izstradajot
web aplikaciju - Stavoklu parvaldiba (state management)
- Darba plusma (workflow)
- Validacija
- Spring web ietvars ir uzprojektets, lai palidzet
izstradatajiem risinat Å¡is problemas
4Model-View-Controller Pattern
- Model-View-Controller (MVC) ir arhitekturas
paraugs (aprakstits 1979. gada, Smalltalk valoda) - Pamata merkis atdalit datus (Model) no
- lietotaja interfeisa (View)
- MVC atrisina
- problemu ieviešot
- starpnieka komponenti - kontrolieri (Controller)
5Model-View-Controller Pattern
- Model - Represents enterprise data and the
business rules. - View - Renders the contents of a model. Accesses
enterprise data through the model and specifies
how that data should be presented. - Controller - Translates interactions
- with the view (button clicks,
- menu selections) into actions to be
- performed by the model
- (activating processes, changing
- the state of the model).
6Spring MVC
- Spring MVC sastav no vairakiem komponentiem,
starp kuriem notiek sadarbiba apstradajot klienta
pieprasijumu
7Pieprasijuma dzives cikls (1)
- Klients suta pieprasijumu, kurš tiek nodots
DispatcherServlet komponentam - Visi pieprasijumi vienmer tiek nodoti vienam
servletam, - kuru sauc par
- priekšejo kontrolieri
- (front controller)
8Pieprasijuma dzives cikls (2)
- Komponents, kurš atbild par pieprasijuma apstradi
ir Controller - Lai nolemt kuram kontrolierim atdot
- pieprasijumu,
- DispatcherController
- izmanto
- HandlerMapping
- komponentus
- HandlerMapping
- URL piesaistišana kontrolieriem
9Pieprasijuma dzives cikls (3-4)
- Kad DispatcherServlet nolemj par kontroliera
objektu, tad parsuta tam pieprasijumu, lai
kontrolieris izpilda biznesa logiku - Pec darba pabeigšanas Controller atgriež
ModelAndView - objektu
- ModelAndView satur
- View objektu vai
- skata logisko vardu
10Pieprasijuma dzives cikls (5)
- Ja ModelAndView objekts satur skata logisko
vardu, tad DispatcherServlet izmanto ViewResolver
komponenti - ViewResolver
- atrod atbilstošu
- View objektu,
- lai attelot atbildi
- klientam
11Pieprasijuma dzives cikls (6)
- Visbeidzot, DispatcherServlet atdod pieprasijumu
tam View objektam, uz kuru norada ModelAndView - View objekts ir
- atbildigs par
- pieprasijuma
- atbildes atgriešanu
- un paradišanu
- klientam
12Spring MVC Sequence Diagram
13Front Controller
- At the heart of Spring MVC is DispatcherServlet,
a servlet that functions as front controller - A front controller is a common web-application
pattern where a single servlet delegates
responsibility for a request to other components
of an application to perform the actual processing
14DispatcherServlet config
- Jakonfigure web aplikacijas web.xml faila
ltservletgt ltservlet-namegttraininglt/servlet-namegt
ltservlet-classgtorg.springframework.web.servlet.D
ispatcherServlet lt/servlet-classgt
ltload-on-startupgt1lt/load-on-startupgt lt/servletgt
- Nakamais solis ir nodefinet servlet mapping
ltservlet-mappinggt ltservlet-namegttraininglt/servlet
-namegt lturl-patterngt.htmlt/url-patterngt lt/servlet
-mappinggt
15DispatcherServlet context
- WebApplicationContext tiek ieladets no faila
- training-servlet.xml
- kurš atrodas direktorija WEB-INF
(lidzigi web.xml failam) - Ir iespejams ari sadalit
- konfiguraciju starp
- vairakiem failiem
16Vienkaršas Web lapas izveidošana
- Nepieciešamie soli, lai izveidot web lapu ar
Spring MVC - Uzrakstit kontroliera klasi, kas izpildis biznesa
logiku - Iekonfiguret kontrolieri DispatcherServlet
konteksta konfiguracijas faila (training-servlet.x
ml) - Iekonfiguret view resolver, kurš piesaistis
kontrolieri pie JSP - Uzrakstit JSP, kas attelos lapu klientam
17Kontroliera izveidošana
public class HomeController implements Controller
public ModelAndView handleRequest(HttpServl
etRequest request,
HttpServletResponse response) throws Exception
return new ModelAndView("home", "message",
greeting) private String greeting
public void setGreeting(String greeting)
this.greeting greeting
- Nodarbojas ar pieprasijuma apstradašanu
- Pamata metodes signatura ir lidziga servleta
service() metodei - Atgriež ModelAndView objektu
18Kontroliera konfigurešana
- Kontrolieri ir jaieraksta DispatcherServlet
konteksta konfiguracijas faila
ltbean name"/home.htm" class"com.springinacti
on.training.mvc.HomeController"gt ltproperty
name"greeting"gt ltvaluegtWelcome to Spring
Training!lt/valuegt lt/propertygt lt/beangt
- The default handler mapping is BeanNameUrlHandlerM
apping, which uses the base name as the URL
pattern - When a request comes with a URL that ends with
/home.htm, DispatcherServlet will dispatch the
request to HomeController
19View Resolver deklarešana
- View resolver darbs ir pec skata logiska varda
(kurš ir atgriezts ModelAndView objekta) atrast
pašu skatu - Viens no variantiem ir izmantot skata vardu ka
JSP faila vardu
ltbean id"viewResolver" class"org.springframework
.web. servlet.view.InternalResourceViewResolver"gt
ltproperty name"prefix"gt
ltvaluegt/WEB-INF/jsp/lt/valuegt lt/propertygt
ltproperty name"suffix"gt
ltvaluegt.jsplt/valuegt lt/propertygt lt/beangt
home ? /WEB-INF/jsp/home.jsp
20JSP izveidošana
- Pedejais kas palika izveidot pašu JSP
lthtmlgt ltheadgtlttitlegtSpring Training,
Inc.lt/titlegtlt/headgt ltbodygt lth2gtmessagelt/h2gt lt/b
odygt lt/htmlgt
- Failu ir janosauc par home.jsp un ir janoliek
zem /WEB-INF/jsp/ direktorijas
21Kopsavilkums
22HandlerMapping
- Tipiski piesaista specifisku kontrolieri pie URL
adreses parauga - Spring piedava cetras noderigas HandlerMapping
implementacijas - BeanNameUrlHandlerMapping
- SimpleUrlHandlerMapping
- CommonsPathMapHandlerMapping
23BeanNameUrlHandlerMapping
- Piesaista URL adresi pie kontroliera, kurš ir
registrets konfiguracijas faila ar tadu pašu
vardu - e.g. /simple.htm maps to a bean named
/simple.htm - Ir jaizmanto name atributu, jo / nav atlauts
XML atributa id
ltbean class"org.springframework.web.servlet.
handler.BeanNameUrlHandlerMapping"/gt ltbean
name"/simple.htm" class"com.mvc.web.Si
mpleController"gt . . . lt/beangt
24SimpleUrlHandlerMapping
- Pats visparigs veids ka piesaistit pieprasijuma
URLus kontrolieriem - Tiek konfigurets ka saraksts no name/value pariem
(URL/kontrolieru vards)
ltbean id"simpleUrlMapping" class"org.springframe
work.web .servlet.handler.SimpleUrlHandler
Mapping"gt ltproperty name"mappings"gt ltpropsgt
ltprop key"/listCourses.htm"gtlistCoursesController
lt/propgt ltprop key"/register.htm"gtregisterStuden
tControllerlt/propgt ltprop key"/displayCourse.htm
"gtdisplayCourseControllerlt/propgt lt/propsgt
lt/propertygt lt/beangt
25CommonsPathMapHandlerMapping
- Considers source-level metadata placed in a
controllers source code to determine the URL
mapping - Need to set up build to
- include the Commons
- Attributes compiler so
- that the attributes will
- be compiled into
- application code
ltbean id"urlMapping" class"org.springframework.w
eb. servlet.handler.metadata.CommonsPathMapHandle
rMapping"/gt
/ _at__at_org.springframework.web.servlet.
handler.commonsattributes.PathMap( "/displayCours
e.htm") / public class DisplayCourseController ex
tends AbstractCommandController
26Multiple handler mappings
- Ir iespejams deklaret vairakus handler mappings
viena aplikacija - Handler mapping klases implemente Springa
Ordered interfeisu - Var uzstadit order ipašibu, lai noradit izpildes
kartibu attieciba uz citiem handler mapping
komponentiem
27Multiple handler mappings
- ltbean id"beanNameUrlMapping" class"org.springfra
mework.web. - servlet.handler.BeanNameUrlHandlerMapping"gt
- ltproperty name"order"gtltvaluegt1lt/valuegtlt/propert
ygt - lt/beangt
- ltbean id"simpleUrlMapping" class"org.springframe
work.web. - servlet.handler.SimpleUrlHandlerMapping"gt
- ltproperty name"order"gtltvaluegt0lt/valuegtlt/propert
ygt - ltproperty name"mappings"gt
-
- lt/propertygt
- lt/beangt
28Kontrolieri
- Ja DispatcherServlet ir Spring MVC sirds, tad
kontrolieri ir smadzenes
29Kontrolieru hierarhija
- Spring piedava
- bagatu kontrolieru
- hierarhiju
- Hierarhijas virsotne
- atrodas Controller
- interfeiss
- Parasti ir jaizmanto
- kadu no
- implementacijas
- apakšklasem
30AbstractController
- Pats vienkaršakais kontrolieris
public class SampleController extends
AbstractController public ModelAndView
handleRequestInternal( HttpServletRequest
request, HttpServletResponse response)
throws Exception return new
ModelAndView( "hello, message, "Hello
World!")
31ModelAndView objekts
- Iekapsule skatu un modela datus, kurus skats
attelos - Modelis ir realizets ka java.util.Map
- Erts konstruktors viena modela objekta gadijumam
- ModelAndView(
- String viewName,
- String modelName,
- Object modelObject)
32ModelAndView objekts
- Ir iespejams ari pievienot modelim vairakus
objektus
public ModelAndView handleRequestInternal(
HttpServletRequest request,
HttpServletResponse response) throws Exception
ModelAndView mav new ModelAndView(welcom
e") mav.addObject("message1", Welcome!")
mav.addObject("message2", "Nice to see you!")
return mav
33Parametru apstrade
- Web pieprasijums bieži satur vienu vai vairakus
parametrus
ltform action"/login" method"POST"gt Login
ltinput idlogin" name"login"/gt Password
ltinput id"password" name"password"
type"password"/gt ltinput type"submit"
value"Login"/gt lt/formgt
Kada veida varetu pieklut parametriem kontroliera
koda???
34Risinajums
- Varetu izmantot AbstractController un nolasit
parametrus no HttpServletRequest
public ModelAndView handleRequestInternal(
HttpServletRequest request,
HttpServletResponse response) throws Exception
String login request.getParameter("login"
) String pass request.getParameter(
"password") . . .
Spring piedava ertaku iespeju!
35AbstractCommandController
- Automatiski ieraksta parametrus specialaja
komandas objekta (command object) - Ir iespeja pievienot validatoru, lai nodrošinat
to, ka parametri ir pareizi - Galvena izpildes metode
- handle(
- HttpServletRequest request,
- HttpServletResponse response,
- Object command,
- BindException errors)
36AbstractCommandController
- public class DisplayCourseController extends
AbstractCommandController - public DisplayCourseController()
- setCommandClass(DisplayCourseCommand.class)
-
- protected ModelAndView handle(HttpServletRequest
request, - HttpServletResponse response, Object command,
- BindException errors) throws Exception
- DisplayCourseCommand displayCommand
- (DisplayCourseCommand) command
- Course course courseService.getCourse(displ
ayCommand.getId()) - return new ModelAndView("courseDetail",
"course", course)
37Command Object
- A command object is a bean that is meant to hold
request parameters for easy access
public class DisplayCourseCommand private
Integer id public void setId(Integer id)
this.id id public Integer getId()
return id
- Spring will attempt to match any parameters
passed in the request to properties in the
command object
38Parskats
39Formu apstrade
- Tipiska web aplikacija satur vismaz vienu formu
- Lietotajs aizpilda formu un aizsuta to
- Dati tiek nosutiti serverim
- Kad datu apstrade ir pabeigta, tad lietotajs
sanem vienu no variantiem - Lapa ar veiksmigas izpildes pazinojumu
- Formas lapa ar kludu pazinojumiem
Kada veida varetu to realizet???
40Risinajums
- Izmantot AbstractController formas attelošanai
- Izmantot AbstractCommandController formas
apstradei - Trukums vajag uzturet divus dažadus
kontrolierus, kuri kopa nodarbojas ar viena
uzdevuma risinašanu
41SimpleFormController
- Formu kontroliera funkcionalitate
- Attelo formu uz HTTP GET pieprasijuma
- Apstrada formu uz HTTP POST pieprasijuma
- Ja notiek kluda, tad atkartoti parada formu
public class RegisterStudentController extends
SimpleFormController public RegisterStudentCont
roller() setCommandClass(Student.class) p
rotected void doSubmitAction(Object
command) throws Exception Student student
(Student) command studentService.enrollStudent(
student)
42SimpleFormController config
- Kontrolieris ir uzprojektets tada veida, lai pec
iespejas vairak atdalit skatu detalas no
kontroliera koda
ltbean id"registerStudentController"
class"com.springinaction. training.mvc.Registe
rStudentController"gt ltproperty
name"formView"gt ltvaluegtnewStudentFormlt/valuegt
lt/propertygt ltproperty name"successView"gt ltvalu
egtstudentWelcomelt/valuegt lt/propertygt . .
. lt/beangt
HTTP GET
- Ja ir nepieciešams aizsutit datus skatam, tad
vajag izmantot onSubmit() metodi
43Formu validacija
- Viens no svarigiem uzdevumiem ir formas datu
validacija - Par validaciju atbild sekojošais interfeiss
public interface Validator void
validate(Object obj, Errors errors) boolean
supports(Class clazz)
- Implementejot Å¡i interfeisa validate() metodi
vajag parbaudit objekta atributu vertibas un
noraidit nepareizas vertibas izmantojot Errors
objektu
44Validatora registrešana
- Validatoru vajag piesaistit kontrolierim
konfiguracijas faila
ltbean id"registerStudentController"
class"com.springinaction.training.mvc.
RegisterStudentController"gt ltproperty
name"validator"gt ltbean class"com.springinac
tion.training. mvc.StudentValidator"/gt
lt/propertygt lt/beangt
45Wizard (daudzekranu) formas
- Uzdevums realizet aptaujas formu ar 40
jautajumiem
Kada veida varetu to realizet???
- Variants izmantot SimpleFormController,
izvietot visus jautajumus viena lapa - Bet tas nav erti lietotajam!
46Wizard formas
- Spring piedava kontrolieri, kas atbild par secigu
virzišanos cauri vairakam lapam - AbstractWizardFormController
- Lidzigs parastai formai, bet ir iespejams validet
datus pa dalam (katra ekrana savu dalu) - Formas apstrade parasti notek pašas beigas
- Ir iespeja visu procesu atcelt (cancel) jebkura
bridi
47Wizard formas kontrolieris
- public class FeedbackWizardController
- extends AbstractWizardFormController
- public FeedbackWizardController()
- setCommandClass(FeedbackSurvey.class)
-
- protected ModelAndView processFinish(
- HttpServletRequest request,
- HttpServletResponse response, Object command,
- BindException errors) throws Exception
- FeedbackSurvey feedback (FeedbackSurvey)
command - feedbackService.submitFeedback(feedback)
- return new ModelAndView("thankyou")
48Wizard formas konfigurešana
- Formas kontroliera konfigurešana
ltbean id"feedbackController" class"com.springina
ction. training.mvc.MyWizardController"gt ltprope
rty name"pages"gt ltlistgt
ltvaluegtgenerallt/valuegt ltvaluegtinstructorlt/
valuegt ltvaluegtcourselt/valuegt
lt/listgt lt/propertygt lt/beangt
- Å eit tiek definetas visas lapas
49Wizard formas lapas
- Pa lapam var parvietoties ierakstot pieprasijuma
parametru ar vardu "_targetX", kur X ir lapas
numurs
ltform method"POST" action"feedback.htm"gt ltinpu
t type"submit" value"Back" name"_target1"gt
ltinput type"submit" value"Next"
name"_target3"gt lt/formgt
50Wizard formas finish/cancel
- Formas pabeigšana - tiks izsaukta metode
processFinish()
ltinput type"submit" value"Finish"
name"_finish"gt
- Formas atcelšana - tiks izsaukta metode
processCancel()
ltinput type"submit" value"Cancel"
name"_cancel"gt
51Wizard formas validacija
- Formas komandas objekts tiek validets pa lapam
protected void validatePage( Object command,
Errors errors, int page) FeedbackSurvey
feedback (FeedbackSurvey) command FeedbackValid
ator validator (FeedbackValidator)
getValidator() if(page 0)
validator.validateEmail(feedback.getEmail(),
errors)
52Vairaku darbibu apstrade
- Visi lidz Å¡im apskatitie kontrolieri pildija kadu
vienu uzdevumu - Veidot vairakus kontrolierus lai pildit lidzigus
uzdevumus nav isti racionali - Piemeram, vajag attelot kursu sarakstu dažados
variantos - Nesakartota veida
- Sakartoti pec datuma
- Sakartoti pec nosaukuma
Kada veida varetu to realizet???
53MultiActionController
- public class ListCoursesController
- extends MultiActionController
- public ModelAndView coursesUnsorted(
- HttpServletRequest request, HttpServletResponse
response) - . . .
-
- public ModelAndView coursesSortedByStartDate(
- HttpServletRequest request, HttpServletResponse
response) - . . .
-
- public ModelAndView coursesSortedByName(
- HttpServletRequest request, HttpServletResponse
response) - . . .
54Metodes varda noteikšana
- Pec noklusejuma metodes vards tiek noteikts
izmantojot URL sastavdalu - http///coursesUnsorted.htm ?
coursesUnsorted() - http///coursesSortedByStartDate.htm ?
coursesSortedByStartDate() - http///coursesSortedByName.htm ?
coursesSortedByName()
55Metodes varda noteikšana
- Ir pieejami ari citi varianti
- ParameterMethodNameResolver - Resolves the
execution method name based on a parameter in the
request - PropertiesMethodNameResolver -Resolves the name
of the execution method by consulting a list of
key/value pairs
56Parskats
57ThrowawayController
- Nav Controller hierarhijas dala
- Netiek izmantots HTTP pieprasijums vai komandas
objekts - Parametri tiek ierakstiti tieši kontrolieri
- Ir noderigi, kad nav modela objekta, kuru varetu
izmantot - Atškiriba no citiem kontrolieriem, nav singleton
public interface ThrowawayController
ModelAndView execute() throws Exception
58ThrowawayController
- public class DisplayCourseController
- implements ThrowawayController
- private Integer id
- public void setId(Integer id) this.id id
- public ModelAndView execute() throws Exception
- Course course courseService.getCourse(id)
- return new ModelAndView(
- "courseDetail", "course", course)
-
59Interceptors
- Iespeja pievienot papildus funkcionalitati pirms
un pec pieprasijuma - Satur divas interception metodes
- preHandle un postHandle
- Satur vienu callback metodi
- afterCompletion
- Tiek piesaistits kontrolieru kopai kopa ar
HandlerMapping
60Piemers Interceptor config
- ltbeansgt
- ltbean id"handlerMapping" class"org.springfra
mework.web. - servlet.handler.SimpleUrlHandlerMapping"gt
- ltproperty name"interceptors"gt
- ltlistgt
- ltref bean"officeHoursInterceptor"
/gt - lt/listgt
- lt/propertygt
- ltproperty name"mappings"gt
- ltvaluegt
- /.formeditAccountFormController
- lt/valuegt
- lt/propertygt
- lt/beangt
- ltbean id"officeHoursInterceptor"
- class"samples.TimeBasedAccessIntercepto
r"gt - ltproperty name"openingTime" value"9"/gt
- ltproperty name"closingTime" value"18"/gt
61Piemers Interceptor kods
- public class TimeBasedAccessInterceptor extends
HandlerInterceptorAdapter - . . .
- public boolean preHandle(HttpServletRequest
request, - HttpServletResponse response,
- Object handler) throws Exception
- Calendar cal Calendar.getInstance()
- int hour cal.get(HOUR_OF_DAY)
- if (openingTime lt hour lt closingTime)
- return true
- else
- response.sendRedirect(
- "http//host.com/outsideOfficeHours.html")
- return false
-
-
62View Resolving
- A view is a bean that renders results to the user
- Spring MVC consults view resolvers when trying to
determine which View bean to use
63ViewResolver implementacijas
- Spring piedava cetras pamata ViewResolver
interfeisa implementacijas - InternalResourceViewResolver
- Resolves logical view names into View objects
that are rendered using template file resources
(such as JSPs and Velocity templates) - BeanNameViewResolver -
- Resolves logical view names into View beans in
the DispatcherServlets application context
64ViewResolver implementacijas
- ResourceBundleViewResolver
- Mappings are contained within a properties file
- Supports internationalization
- XmlViewResolver
- Mappings are contained within a XML file that is
separate from the DispatcherServlets application
context - VelocityViewResolver
- FreeMarkerViewResolver
65View klases
- Spring piedava sekojošas skatu apakšklases
- JstlView
- Attelo viewName par JSP lapu, kura uzstaditi ari
JSTL tagu bibliotekam vajadzigie mainigie,
piemeram, lokalizacija. - RedirectView
- Veic HTTP Redirect
- VelocityLayoutView, VelocityToolboxView,
VelocityView - Velocity skati ar vai bez papildu objektiem, ko
konfigure toolbox.xml - FreeMarkerView
66Internacionalizacija
- Spring dod iespeju automatiski izveleties
zinojumu tekstus izmantojot lietotaja lokali - DispatcherServlet izmanto LocaleResolver lai
noteikt klienta lokali - AcceptHeaderLocaleResolver
- izmantot HTTP "Accept-language" hederi lokales
atrašanai - CookieLocaleResolver
- izmantot cookies lokales atrašanai
- SessionLocaleResolver
- lokale liek glabata sesija
67Internacionalizacija
- Lokales izmainas funkcionalitatei var izmantot
klasi LocaleChangeInterceptor, to ir japieliek
klat kadam HandlerMapping - Visbeidzot, teksta zinojumus ir jaieraksta failos
zem /WEB-INF/classes/ - messages_en.properties
- messages_de.properties
- utml
- JSP lapa zinojumus var ielikt izmantojot tagu
- ltfmfmessage key"ltmsg_namegt"gt
- ltfmfmessage keyhello"gt
msg_namemsg_text greetingsHello! trueYes false
No
68Springa temas
- Viegli konfigurejamas un izpildes laika
nomainamas aplikacijas "adas
69Springa temas
- Tema (theme) ir statisko resursu kolekcija, kas
ietekme aplikacijas vizualo stilu - style sheets (css), images
- ResourceBundleThemeSource ielade properties
failus no classpath saknes - /WEB-INF/classes/
- Daudz lidzibas ar internacionalizacijas
konfigurešanu
70Springa temas
styleSheet/themes/cool/style.css
background/themes/cool/img/coolBg.jpg
- JSP lapa ir jaizmanto ltspringthemegt tagu
lt_at_ taglib prefix"spring" uri"http//www.sprin
gframework.org/tags"gt lthtmlgt ltheadgt
ltlink rel"stylesheet" href"ltspringtheme
code"styleSheet"/gt" type"text/css"/gt
lt/headgt ltbody background"ltspringtheme
code"background"/gt"gt ... lt/bodygt lt/htmlgt
71Failu augšupielade
- Spring piedava failu augšupielades
funkcionalitati (multipart file upload) - Atbalsta CommonFileUpload un COS FileUpload
lth1gtPlease upload a filelt/h1gt ltform method"post"
action"upload.form" enctype"multipart/form-dat
a"gt ltinput type"file" name"file"/gt ltinput
type"submit"/gt lt/formgt
ltbean id"multipartResolver class"org.springfram
ework. web.multipart.commons.CommonsMultipartRes
olver"gt ltproperty name"maxUploadSize"
value"100000"/gt lt/beangt
72Iznemumu apstrade
- Viena no Springa ipatnibam - vairums iznemumu ir
RuntimeException apakštipi, tos nevajag metodes
kert vai deklaret - Ir piedavata iespeja apstradat negaiditas kludas
- SimpleMappingExceptionResolver
- Iespeja piesaistit skatu iznemuma klasei
konfiguracijas faila - HandlerExceptionResolver
- Interfeiss, kuru vajag implementet, lai apstradat
kontrolieru kludas
73SimpleMappingExceptionResolver
- ltbean id"exceptionResolver" class"org.springfra
mework.web. - servlet.handler.
- SimpleMappingExceptionResolver"gt
- ltproperty name"exceptionMappings"gt
- ltpropsgt
- ltprop key"java.lang.Exception"gt
- friendlyError
- lt/propgt
- lt/propsgt
- lt/propertygt
- lt/beangt
74Countries piemers
- Spring piemeru, kuru var palaist un apskatities
kodu var atrast zem - \spring-framework-2.0.6\samples\countries\
- Special Spring MVC features
- paged list navigation
- locale and theme switching
- localized view definitions
- page composition through
- view definitions
- generation of PDF and
- Excel views
75Resursi
- Spring Home
- http//www.springframework.org
- C. Walls, R.Breidenbach. Spring in Action
http//www.manning.com/walls2/ - Spring Web MVC Framework http//www.springframewor
k.org/docs/reference/mvc.html - Spring MVC step-by-step Tutorial
- http//www.springframework.org/docs/MVC-step-by-s
tep/Spring-MVC-step-by-step.html
76Resursi
- Model-View-Controller pattern by Sun
http//java.sun.com/blueprints/patterns/MVC.html - Core J2EE Patterns - Front Controller
http//java.sun.com/blueprints/corej2eepatterns/Pa
tterns/FrontController.html