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