Spring 3 MVC Tutorials, Tips & Tricks

Spring MVC is the web component of Spring’s framework. It provides a rich functionality for building robust Web Applications. The Spring MVC Framework is architected and designed in such a way that every piece of logic and functionality is highly configurable. Also Spring can integrate effortlessly with other popular Web Frameworks like Struts, WebWork, Java Server Faces and Tapestry. It means that you can even instruct Spring to use any one of the Web Frameworks. More than that Spring is not tightly coupled with Servlets or JSP to render the View to the Clients. Integration with other View technologies like Velocity, Freemarker, Excel or Pdf is also possible now.

Spring MVC Flash Attribute tutorial with example

Spring MVC Flash Attribute tutorial with example
Spring MVC 3.1 version has added a very useful feature Flash attribute which it lacked and is now solving a long time problem of POST/Redirect/GET pattern.In a normal Web based MVC application each form submitted POST the data to the server. A normal spring controller (tagged with annotation @Controller) fetches the data from request and process it further (save or update in database). Once ...

Spring 3 MVC Interceptor tutorial with example

Spring 3 MVC Interceptor tutorial with example
Spring MVC provides a powerful mechanism to intercept an http request. Similar to Servlet Filter concept, Spring MVC provides a way to define special classes called Interceptors that gets called before and after a request is served.Quick OverviewEach interceptor you define must implement org.springframework.web.servlet.HandlerInterceptor interface. There are three methods that need to be implemented.preHandle(..) is called before the actual handler is executed;The ...

Solve:Errors/BindingResult argument declared without preceding model attribute

Sometimes Spring MVC will amaze you with totally unexpected exceptions. You have no idea why that is coming.For instance, recently I wrote a small piece of Spring MVC Controller code, one like below:@Controller public class UserController {@RequestMapping(value = "addUser") public String addUser(@ModelAttribute("userForm") UserForm userForm, ModelMap map, BindingResult results) {if (results.hasErrors()) { return "add_user_form"; }return "add_user_success"; } //... }And while executing the application, I got a strange exception:Throwable occurred: java.lang.IllegalStateException: Errors/BindingResult argument declared ...

Spring MVC Multiple File Upload example

Spring MVC Multiple File Upload example
In this simple tutorial we will see how to implement multiple file upload in a Spring 3 MVC based application.The requirement is simple. We have a form which displays file input component. User selects a file and upload it. Also its possible to add more file input components using Add button. Once the files are selected and uploaded, the file names are displayed on success ...

Spring MVC HashMap Form Integration example

Spring MVC HashMap Form Integration example
Spring MVC provides powerful way to manage form inputs. It also provides form validation functionality which is easy to integrate in any application. But other than the normal form bean mapping, recently I had a requirement to map dynamic values like key-value pairs in an HTML form and retrieve the same in Spring Controller. So basically HashMap came to rescue.Let us see how ...

Spring MVC + FreeMarker (FTL) Integration example

Spring MVC + FreeMarker (FTL) Integration example
Welcome to Freemarker Tutorial Series. In previous post we created Servlet based Hello World Freemarker Template example. We learned few APIs of freemarker and also how to integrate it with Servlet based application. Following are the list of tutorials from Freemarker tutorial series.Today we will create a Spring MVC based application that uses Freemarker FTL as view instead of JSP. This would give you ...

Spring 3 MVC – Autocomplete with JQuery & JSON example

Spring 3 MVC - Autocomplete with JQuery & JSON example
Let us implement Autocomplete feature in Spring MVC application using JQuery. Autocomplete is a feature you''ll see in almost all good web apps. It allows user to select proper values from a list of items. Adding this feature is recommended if the field has multiple ( > 20 to 25) values.Related: Autocomplete in Java / JSPOur requirement is simple. We will have ...

Spring MVC: Multiple Row Form Submit using List of Beans

Spring MVC: Multiple Row Form Submit using List of Beans
Recently I had a requirement where using Spring MVC we had to take inputs multiple rows of data from user. The form had many rows which user can edit and submit. Spring MVC provides very simple yet elegant way of collecting data from multiple rows from HTML form and store them in List of Beans in Java.Lets look at the requirement first. We have a ...

Change spring-servlet.xml Filename (Spring Web Contenxt Configuration Filename)

The first thing that we do when we want to implement Spring MVC in our project is to add DispatcherServlets entry in deployment descriptor (web.xml). Also we write a spring web configuration xxxx-servlet.xml which contains all the MVC mappings and data.By default the name of file must be XXX-servlet.xml where XXX is the name ...

Tutorial:Saving/Retreving BLOB object in Spring 3 MVC and Hibernate

Tutorial:Saving/Retreving BLOB object in Spring 3 MVC and Hibernate
Working with BLOB / CLOB data types in database is sometime a trivial task. I found particularly when working with Hibernate 3 to store and retrieve BLOB objects we need certain things to be taken care of. Let us see a tutorial where we will using Spring 3 MVC and Hibernate 3 to store and retrieve ...
Page 1 of 212