Spring MVC Google Places Autocomplete

In this tutorial, we will use Google Places API with Spring MVC in a simple web application to provide an input to search for locations with an autocomplete dropdown.

 

1. Technologies used

  • Spring 3.2.8.RELEASE
  • Google Places API
  • JQuery-1.10.2

 

2. Project structure

We create a new web application project.

Spring-MVC-Google-Places-Autocomplete-Example-1

 

3. Project dependencies

File : pom.xml

 

4. JSP View

File : index.jsp

The autocomplete plugin will generate the suggestions list based on data returned by the PlacesController.

 

5. Spring MVC Controller

It will process the request and returns the locations list.

 

6. Places utility

In this class, we will call Google Places service to get suggested locations based on input value on JSP page.

To use Places API, we need an API key; we can have one by following the steps on this URL.

 

7. Spring MVC Configuration

File : mvc-dispatcher-servlet.xml

 

8. Web app configuration

File : web.xml

 

9. Test It

Url : http://localhost:8080/Spring-MVC-Google-Places-Autocomplete/

We tape ‘mo‘ :

Spring-MVC-Google-Places-Autocomplete-Example-2

Another example :

Spring-MVC-Google-Places-Autocomplete-Example-3

 

Download source code