Posts

Showing posts with the label Spring

Spring MVC - Spring MVC Introduction

In this example we will give you quick over view of Spring MVC Framework. The Spring MVC framework is the MVC stack for the development of web applications based Model View Controller (MVC) architecture. What is MVC architecture? The MVC or Model View Controller architecture is famous design pattern used in designing the applications. This design pattern separates the application into three parts called Model, View and Controller. Model:  Model is the business data or simple the data of the application. View:  View is the presentation part of the application such as data entry form, reports etc. Controller:   The controller component delegates between Model and view. Spring MVC The Spring Framework is light-weight container and it supports multiple frameworks and libraries. The Spring framework allows the developers to mix and match multiple frameworks while developing and deploying the applications. The Spring MVC takes the advantage of Spring framew...

Bean life cycle in spring

This example gives you an idea on how to Initialize bean in the program and also explains the lifecycle of bean in spring. Run the given bean example to retrieves the values of the bean using java file. Here in the file given below i.e. (context.xml) we have declare the bean definition. <bean id="Mybean" class="Bean">      <property name="company" value="Name"/>   <property name="value" value="Roseindia.net"/>     </bean> Here   "Bean"  is the name of the bean class which would be further referred in the xml file with the id "MyBean". <property name="company" value="Name"/>:- Declares  the property name of the bean and its value. context.xml <?xml version= "1.0"  encoding= "UTF-8" ?> <beans xmlns= "http://www.springframework.org/schema/beans"   xmlns:xsi= "http:/...

init Method in Spring

Calling Bean using init() method in Spring, this section describes  the way to initialize a bean through its lifecycle events using the init()   method .Here we have defined the property and values of  the bean using the init method as shown below:- <bean id="mybean" class="Bean" init-method="init">:- Here "Bean" is the name of the bean class which would be referred in the xml file with the id "mybean". init-method="init":- Specify the init method named   "init"   in the configuration file. <property name="name"> <value>Roseindia.net</value>:- Here the   <property>   element is used to declare the attributes and to pass the desired value to the property element, the   <value>   element is used. Here the property name is   "name" and its value is   "Roseindia.net" . <bean id="mybean" class="Bean" init-method=...

Calling Constructor in Spring

In the given example you will be learning about a constructor and how to call a constructor in the Spring. Declaring constructor injection in the Spring framework is generally done in the bean section of the configuration file that is the context.xml file.  Steps to declare Constructor Injection: 1)Set the constructor declaration 2)Pass the value to the constructor. This tutorial describes the way of defining constructor in the xml document and retrieving the values defined in the constructor using java file. <constructor-arg>     <util:map>   <entry key="CompanyName" value="Roseindia.net"/>   <entry key="Address" value="Rohini"/>   </util:map> </constructor-arg> <constructor-arg>:- This is the way to declare  the constructor injection consisting of arguments. The use of this injection is to tell the container that the application...