In this tutorial I will write a simple example program for parsing a XML file using the DOM parser. DOM parser reads the entire XML file and loads into the memory. It forms a tree structure in the memory and returns the element details when queried. It is the faster when comparing to the SAX …
Difference Between @Resource, @Autowired and @Inject in Spring Injection
It is very common confusion among the spring developers that what is the real difference between these three (@Resource, @Autowired and @Inject) annotations used for injecting the objects. I have come across this question from our readers so dedicated this post for explaining the main difference between these three annotations. Infact, these three work very …
How to use Spring HATEOAS LinkBuilder API with Spring REST?
Hypermedia as the Engine of Application State (HATEOAS) is a constraint for the REST architecture. If you are not familiar with the REST web services, REST is services exposed using an URI that is shared to the clients. A client can directly access that given URI to get the response which is mostly a JSON …
Flash Attributes in Spring MVC 3.1
Spring 3.1 has added new feature called flash attributes. This is one of the most wanted feature from the spring developers. This solves the problem occured when POST/Redirect/Get pattern in the request. When user makes a request to the server via POST method, once the process is completed, the requested resourced will be served through …
Content Negotiation in Spring MVC 3.2
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
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
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
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 …