Spring MVC + jQuery Integration Example

spring-thumbnail

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-thumbnail

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

spring-thumbnail

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

spring-thumbnail

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 […]

Spring MVC Redirect Example

spring-thumbnail

This tutorial explains how to redirect to a new URL inside the Spring MVC controller. There is attribute “redirect” which can be prefixed to the view name to indicate that the new request should be a redirected one. also read: Spring 4 Tutorials Introduction to Spring MVC Framework 1. Spring MVC Controller SpringMVCController.java 2. Views […]

DependsOn Attribute in Spring Configuration

spring-thumbnail

This example shows how to use the dependsOn attribute for loading the depended beans referenced by another bean. dependsOn is a attribute as part of the bean tag and it takes the comma separated bean names which are loaded before the actual bean is instantiated. Lets look at the syntax for using the dependsOn attribute. […]

How To Pass Multiple Parameters To Spring MVC Controller

spring-thumbnail

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 […]

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 […]

Flash Attributes in Spring MVC 3.1

spring

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

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 […]