If you are a spring developer then you might have a small confusion about the annotation processing inside spring’s IOC container. Spring MVC framework provides different configuration elements that are helping or instructing the Spring container to effectively manage the beans and inject the beans when required. Some of the XML configurations that are most …
Spring MVC
Spring MVC – Application Context vs Web Application Context
Understanding the difference between ApplicationContext and WebApplicationContext for Spring developers is important. There are various context names available in the spring framework that are used based on the type of application. The most common ambiguity due to the two different context configuration files used for configuring the spring applications. The question comes to developers mind …
Spring MVC + jQuery Integration Example
This tutorial demonstrates how to integrate Spring MVC and jQuery for developing a web application. This example uses jQuery front end for getting the data from Spring MVC controller. Also the data is used in the text box for the auto completion feature. If you have any questions, please write it in the comments section. …
WebApplicationInitializer in Spring MVC
Spring 3.1 has introduced a new feature for configuring the deployment descriptor using the Java Config approach. We don’t need to write the web.xml file for initializing the web applications. Everything can be done through a Java class itself. The Java class has to implement the org.springframework.web.WebApplicationInitializer which will be loaded when web application starts. …
Spring MVC : How To Return Custom 404 Error Pages
This example provides the steps to write your own 404 Resource Not Found error page for your application. Here I am writing a custom exception for 404 error using the HttpStatus.NOT_FOUND. This will be annotated as the exception @ExceptionHandler in the controller. Whenever there is any error thrown on this type, it will be redirected …
RequestContextHolder in Spring MVC
RequestContextHolder is a spring API for setting the values to any of three scopes request, session or global session. Note that in some situations, we may not be able to get the actual request from the request, we can simply use RequestContextHolder to get the request attributes and set the values. We have to explicitly …
How To Pass Multiple Parameters To Spring MVC Controller
This example shows how to pass the multiple parameters to the Spring controller. In our previous article, I have explained how to use the @PathVariable to pass the parameters to the controller. This example shows a simple example on how to pass multiple parameters using the @PathVariable. 1. Spring Controller HelloController.java 2. Spring Configuration spring-dispatcher-servlet.xml …
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 …