Spring MVC:-
Spring framework is light weighted, non-invasive and loosely coupled framework.
There are following module in spring framework:-

Few Points regarding this:-
1)Working with a frame work software is nothing but working with a set of jars given by that framework.
2)If we want to use spring framework in a java client application then we need to set the framework jars in class path.
Main concepts of spring core(DI):-
Dependency Injection(IoC)-dependency injection is a software design pattern that implements inversion of control. In DI one or more dependencies (or services) are injected, or passed by reference, into a dependent object and It makes our code loosely coupled.
there are two Types of Spring containers:-
1. Spring BeanFactory
2. Spring ApplicationContext Container
we are using Spring ApplicationContext Container in our projects.
ApplicationContext context = new ClassPathXmlApplicationContext("Our Config xml file name ");
Object ob = context. getBean(“id1″);
FirstBean fb = (FirstBean)ob;
Spring JDBC Connection:-
Note:-
1)DriverManagerDataSource is given by spring framework, it means spring framework internally opens a new connection and closes the connection for each operation done on the database.
2)BasicDataSource is given the apache, and this is better than DriverManagerDataSource because BasicDataSource having inbuilt connection pooling implementation.
In spring configuration we need to configure the following 4 properties to obtain connection with database:-
<bean id=”id1” class=”org.springframework.datasource.DriverManagerDataSource”>
[ or ]
<bean id=”id1” class=”org.apache.commons.dbcp.BasicDataSource”>
<property name=”driverClassName” value=”” />
<property name=”url” value=”” />
<property name=”username” value=”” />
<property name=”password” value=”” />
</bean
Spring JDBC Template:-
JdbcTemplate is a class which is given, in org.springframework.jdbc.core.* package and this class will provides methods for executing the SQL commands on a database.
JdbcTemplate class accepts input from the user and produces output to the user by hiding the interval details.
JdbcTemplate class provided the following type of methods to execute SQL operations on the database
1)execute(),
2)update(),
3)query()methods:- queryForInt(), queryForLong(), queryForObject(), queryForList().
Note:- execute and update methods are for non-select operations on the database, and query methods are for select operations on the database.
JdbcTemplate class depends on DataSource object only, as it will opens database connection internally with DataSource. So we must give this DataSource object to JdbcTemplate,
Spring MVC Flow:- “In Spring MVC dispatcher servlet behaves like a front controller which takes all incoming request and dispatch to related controller and controllers are known as handler. And then handler will process the request and sent back the data in the form of Model to front controller and then after front controller select the particular view with the help of view resolver and send response back to client.”

Step By Step:-
1.The Client requests for a Resource in the Web Application.
2.The Spring Front Controller, which is implemented as a Servlet, will intercept the Request and then will try to find out the appropriate Handler Mappings.
3.The Handle Mappings is used to map a request from the Client to its Controller object by browsing over the various Controllers defined in the Configuration file.
4.With the help of Handler Adapters, the Dispatcher Servlet will dispatch the Request to the Controller.
5.The Controller processes the Client Request and returns the Model and the View in the form of ModelAndView object back to the Front Controller.
6.The Front Controller then tries to resolve the actual View (which may be Jsp, Velocity or Free marker) by consulting the View Resolver object.
7.Then the selected View is rendered back to the Client.
Tiles:-
We can customize the layout of the our application by integrating with tiles framework.
A web page can contain many parts (known as tile) such as header, left pane, right pane, body part, footer etc. In tiles framework, we manage all the tile by our Layout Manager page.
There are following advantages of tiles framework:-
1. We can customize the layout of all the pages by single page (centralized page) only.
2. Code reusability (e.g. header or footer can be used in many pages. So it saves coding).
3. Easy to modify If any part (tile) is modified, we don't need to change many pages.
4. Easy to remove If any part (tile) of the page is removed, we don't need to remove the code from all the pages. We can remove the tile from our layout manager page.
tiles integration in Spring MVC:-
1. Add tiles library in your application
2. tiles configuration in view part in application context file.
Example:- Spring MVC With Tiles
Spring framework is light weighted, non-invasive and loosely coupled framework.
There are following module in spring framework:-
Few Points regarding this:-
1)Working with a frame work software is nothing but working with a set of jars given by that framework.
2)If we want to use spring framework in a java client application then we need to set the framework jars in class path.
Main concepts of spring core(DI):-
Dependency Injection(IoC)-dependency injection is a software design pattern that implements inversion of control. In DI one or more dependencies (or services) are injected, or passed by reference, into a dependent object and It makes our code loosely coupled.
there are two Types of Spring containers:-
1. Spring BeanFactory
2. Spring ApplicationContext Container
we are using Spring ApplicationContext Container in our projects.
ApplicationContext context = new ClassPathXmlApplicationContext("Our Config xml file name ");
Object ob = context. getBean(“id1″);
FirstBean fb = (FirstBean)ob;
Spring JDBC Connection:-
Note:-
1)DriverManagerDataSource is given by spring framework, it means spring framework internally opens a new connection and closes the connection for each operation done on the database.
2)BasicDataSource is given the apache, and this is better than DriverManagerDataSource because BasicDataSource having inbuilt connection pooling implementation.
In spring configuration we need to configure the following 4 properties to obtain connection with database:-
<bean id=”id1” class=”org.springframework.datasource.DriverManagerDataSource”>
[ or ]
<bean id=”id1” class=”org.apache.commons.dbcp.BasicDataSource”>
<property name=”driverClassName” value=”” />
<property name=”url” value=”” />
<property name=”username” value=”” />
<property name=”password” value=”” />
</bean
Spring JDBC Template:-
JdbcTemplate is a class which is given, in org.springframework.jdbc.core.* package and this class will provides methods for executing the SQL commands on a database.
JdbcTemplate class accepts input from the user and produces output to the user by hiding the interval details.
JdbcTemplate class provided the following type of methods to execute SQL operations on the database
1)execute(),
2)update(),
3)query()methods:- queryForInt(), queryForLong(), queryForObject(), queryForList().
Note:- execute and update methods are for non-select operations on the database, and query methods are for select operations on the database.
JdbcTemplate class depends on DataSource object only, as it will opens database connection internally with DataSource. So we must give this DataSource object to JdbcTemplate,
Spring MVC Flow:- “In Spring MVC dispatcher servlet behaves like a front controller which takes all incoming request and dispatch to related controller and controllers are known as handler. And then handler will process the request and sent back the data in the form of Model to front controller and then after front controller select the particular view with the help of view resolver and send response back to client.”
Step By Step:-
1.The Client requests for a Resource in the Web Application.
2.The Spring Front Controller, which is implemented as a Servlet, will intercept the Request and then will try to find out the appropriate Handler Mappings.
3.The Handle Mappings is used to map a request from the Client to its Controller object by browsing over the various Controllers defined in the Configuration file.
4.With the help of Handler Adapters, the Dispatcher Servlet will dispatch the Request to the Controller.
5.The Controller processes the Client Request and returns the Model and the View in the form of ModelAndView object back to the Front Controller.
6.The Front Controller then tries to resolve the actual View (which may be Jsp, Velocity or Free marker) by consulting the View Resolver object.
7.Then the selected View is rendered back to the Client.
Tiles:-
We can customize the layout of the our application by integrating with tiles framework.
A web page can contain many parts (known as tile) such as header, left pane, right pane, body part, footer etc. In tiles framework, we manage all the tile by our Layout Manager page.
There are following advantages of tiles framework:-
1. We can customize the layout of all the pages by single page (centralized page) only.
2. Code reusability (e.g. header or footer can be used in many pages. So it saves coding).
3. Easy to modify If any part (tile) is modified, we don't need to change many pages.
4. Easy to remove If any part (tile) of the page is removed, we don't need to remove the code from all the pages. We can remove the tile from our layout manager page.
tiles integration in Spring MVC:-
1. Add tiles library in your application
2. tiles configuration in view part in application context file.
Example:- Spring MVC With Tiles