Introduction

The JavaScript AJAX call is described in terms of request headers and request data formatting.

Spring uses Jackson for JSON parsing. Jackson is configured to ignore extra JSON properties that do not match properties of the bean being populated at the @Controller request end-point method.

This blog demonstrates populating complex objects n levels deep thus overcoming some difficulties encountered as per many of the comments in this blog.

Unlike Spring 3 MVC – Adding Objects to a List element on the fly at form submit – (Generic method) a generic JavaScript library is not provided. Populating JSON objects is easily achieved with JavaScript. For that reason, the difficulties of the HTML form implementation described (and partially solved) in that blog do not arise in the first place. Therefore it is hugely favorable to use JSON over conventional HTML forms for complex objects (and in general).

This demonstration conforms to a useful and popular design pattern. Specifically, the form is submitted asynchronously, the response is handled by the client JavaScript.

This provides for:

A far better user experience as there is no page load. Feedback is immediate.

This blog will go through the steps required to setup a basic Spring 4 MVC web application using Netbeans and Maven. The Spring 4 project will be configured using annotations and plain Java rather than XML.

It is a step by step guide to getting up and running quickly. There are plenty alternative methods to doing this but this one is simple, lightweight and to the point. A maven project is available for download at the end of this blog.