Spring MVC

There are 4 ways to Create a MVC :-
---------------------------------------------------------------------------------------------
Input-Jsp(controler)-Bean(Business)-DAO

Input-Servlet(controler)-Bean(Business)-DAO(Strus1.0,SprinMVC)

Input-Filter(controler)-Bean(Business)-DAO(Struts2.0)

Input-TagLib(controler)-Bean(Business)-DAO

1 and 4 are not in used as MVC . how ever still we have option.

-----------------------------------------------------------------------------------------

Dispatcher Servlet extends FrameWorkServelt extnds HttpServlet Bean inside init()
method of HttpSevelt Bean ..spring.xml.. reading logic written..

ins simple DS init method reads the Spring.xml file.

----------------------------------------------------------
SPRing MVC:---
Form back up support is there in spring mvc because of it's powerful tag libraries...
ex-let we have field like name and age and email, after validation the data let your email is invalidate ..so we
need to show the page with exiting data plus remove the earlier email and show validation error with existing data.
to get this we have spring tag libraries.
---
Validation support
Internationalization support
Interceptor support
Exception Handling
Modularization
-----------
three type of url pattern tomcat support
1:-complete character sequence
2:- /*
3:- *.ext
---
for struts
1.x-  *.do
2.x-  *.action
--------------------
we can configure xml file name;
default case
servlet name
2- init parameter set to contextconfiglocation
---------
3-Context parameter
but you need to set listener
<listner>contextloaderlistener<lisener>



Prototype vs Request scope:--
-----------------------------------------
Prototype creates a brand new instance everytime you call getBean on the ApplicationContext.
Whereas for Request, only one instance is created for an HttpRequest. So in a single HttpRequest,
I can call getBean twice on Application and there will ever be one bean instantiated,
whereas that same bean scoped to Prototype in that same single HttpRequest would get 2 different instances.
HttpRequest scope

Mark mark1 = context.getBean("mark");
Mark mark2 = context.getBean("mark");
mark1 == mark2; //This will return true
Prototype scope

Mark mark1 = context.getBean("mark");
Mark mark2 = context.getBean("mark");
mark1 == mark2; //This will return false
Application context reads the.spring.xml and creates the number of bean object .no matter of 1 request getBean by any object. it creaTES all bean id object as siglton and white
obj.getBean(). it return instance of the class which is precreated.

No comments:

Post a Comment