Archive for category Spring

Spring Object/XML mapping example

In this tutorial we will look into Spring’s Object/XML mapping support. Spring provides an elegant way to convert Object to XML and then XML back to Object. Marshaller and Unmarshaller Spring abstracts all marshalling operations behind the org.springframework.oxm.Marshaller interface, which looks like this. The Marshaller interface has one main method, which marshals the given object […]

, , , ,


Spring 3 MVC and JSON Response

JSON stands for Javascript Object Notation, and is a good alternative of XML for data transfers these these days. To know more about JSON visit In this tutorial we will explore generation of JSON response in Spring MVC. Tools Used Eclipse Tomcat Jackson 1.7.1 Spring 3.x Maven Project Structure This is a maven based […]

, ,


Configuring and using properties file in spring 3

Here in this tutorial we see a couple of ways to configure and use properties file in a spring application. 1st Method Using properties file in spring is simple. Configure it in your spring config file as below. spring-config.xml In your spring config file the string ${jdbc.username} is replaced at runtime with the value […]

, , , ,

1 Comment

Access properties file values in Spring MVC Controller class

Spring 3 provides a clean way to configure and use properties file to store placeholders. Let us assume that we have a properties file and want to use it’s properties in our spring config and java code. Our file looks like below In my spring-servlet.xml config file i configure it like this Note the […]

, , , ,


Spring Constructor Injection

In Spring framework, a dependency can be injected in a couple of ways. Constructor Injection Setter Injection In this example we will visit Spring’s Constructor Injection feature. Here is how my example project’s layout looks like. It’s a maven project, so pom.xml contains basic dependencies. We have a Class Employee Employee has a few dependencies […]

, , , , , , ,

Leave a comment

Interceptor in Spring 3 MVC

Interceptors are very important to a web framework/application. MVC frameworks like Struts 2 implements most of the framework’s functionality via Interceptors. In general intercepts are used for the purpose of implemeting User Authentication, Logging, Hibernate session management via “Open Session in View” design pattern etc. In Spring 3 we can add an interceptor by implementing […]

, , ,

Leave a comment