Register Spring Beans to BeanFactory using registerSingleton

spring

Spring’s strength lies on its core framework’s Inversion Of Control (IOC) and how the beans are instantiated and managed by the IOC container. All the beans in the spring’s IOC containers are managed as the singleton beans by default for the efficient and good performance. As a good practice, you should never create instance for […]

How to use Spring EL in XML configurations?

spring

In our previous tutorial we have explained in detail about how to use the spring expression language. This tutorial is a simple example to demonstrate how to use the expression language in XML configuration file. Employee.java Company.java SpringExpressionDemo.java beans.xml If you run the above example program, you will get the output as: I hope this […]

Use @Import for Importing JavaConfig Files in Spring Projects

spring

In my previous article I have explained about the JavaConfig in Spring 3.0. It is a new way of configuring the bean definitions without using the traditional XML files. Also I have listed the annotations defined as part of JavaConfig approach. In the list, @Import is the one such annotation used for consolidating all the […]

JavaConfig in Spring 3.0

spring

Spring 3.0 has introduced new way for configuring the spring beans. In fact this was maintained by spring framework separately as JavaConfig. Later it is merged to the spring core framework and all the features are directly accessible from the spring core. Instead of using the XML files, we can use plain Java classes to […]

Configure Multiple View Resolvers in Spring MVC

spring

In my previous tutorial I have explined about content negotiation startegy introduced in Spring MVC 3.2. This tutorial focuses on how to configure multiple view resolvers for your spring web application. We have different view resolvers for different purposes : XmlViewResolver, ResourceBundleViewResolver, and InternalResourceViewResolver. XmlViewResolver: An implementation of ViewResolver that accepts a configuration file written […]

Content Negotiation in Spring MVC 3.2

spring

In this tutorial I will explain about the Content Negotiation in Spring MVC 3.2. This concept is already in the spring framework, but it is enhanced with easy and efficient resolution of views. Prior to Spring 3.2, @ResponseBody used “AcceptHeader” for identifying the response type. This tutorial will helps you to understand the concept behind the […]

@ModelAttribute in Spring MVC

spring

In this tutorial I will explain one of the most important annotation used in Spring MVC @ModelAttribute. This annotation can be used as the method arguments or before the method declaration. The primary objective of this annotation to bind the request parameters or form fields to an model object. The model object can be formed […]

@RequestHeader in Spring MVC

spring

In this tutorial, I would go through an example for how to use @RequestHeader annotation. Every request has a request header part with the set of details sent to the web server. Typically request headers contains the details about browser version, language, what it will accept from the server, etc. are sent to inform the […]

Exception Handling With @ControllerAdvice in Spring 3.2

spring

In my previous article I have explained one of the new feature Spring MVC Test Fraemwork which is introduced as part of the Spring Framework 3.2 release. This tutorial explains another good feature for exception handling on Spring MVC web application. Spring 3.2 introduces new annotation @ControllerAdvice annotation used for defining the exception handler with specific exception […]

@PathVariable – URI Template Patterns in Spring MVC

spring

This tutorial explains how to customize / template pattern on  request URI for Spring MVC web application. @RequestMapping annotation used for defining the request URL for the class level and method levels. It is generic annotation where developer can configure the relative paths inside application context. However, it doesn’t offer flexible URI patterns on its own. […]