Location Labs

  • Company
  • Products
  • Blog
  • Facebook
  • Twitter
  • YouTube
[icon] Universal Location Service

Universal Location Service

  • Overview
  • My Apps
  • Tutorials
  • Test Tools
  • SDK
  • Developer Guide
  • Billing
  • Support
  • Register
  • Sign In

Using Spring MVC

Using the Web Tier Java SDK

  • About the Web Tier Java SDK
  • Using Java Server Pages
  • Inheriting from AbstractVeriplaceServlet
  • Using Spring MVC
  • < back to all tutorials

Using Spring MVC (back to all tutorials)

Many web applications leverage the Model-View-Controller (MVC) architecture to promote modularity, testability, and maintainability. The popular Spring Framework supports this architecture and can be used in conjunction with the Veriplace API to build large, maintainable applications.

  1. Step 1: Writing PageController.java

    The SDK supports adding location to any common Spring controller using an interceptor. The interceptor itself is declared in your application's Spring configuration; the controller can derive from any Spring base class:

    The VeriplaceState.getFromRequest() method provides access to the request's VeriplaceState and any data, including location, obtained from Veriplace.

  2. Step 2: Writing page.jsp

    As with the Servlet example above, PageController.java uses a JSP view:

  3. Step 3: Configuring web.xml

    Spring-based applications are typically configured using Spring bean declarations. As such, your application's web.xml file only needs to declare the Spring dispatcher servlet:

  4. Step 4: Configuring dispatcher-servlet.xml

    The Spring dispatcher servlet will read its configuration from dispatcher-servlet.xml. This configuration file needs to contain all of the same information required by the JSP and Servlet examples:

    The PropertiesFactoryBean loads your application's OAuth credentials. These are passed to an instance of com.veriplace.web.Veriplace, which manages all application state related to Veriplace.

    The statusViewResolver defines waiting and error views.

    The com.veriplace.web.spring.LocationDiscoveryInterceptor enforce that Veriplace API calls have been made before control is passed to your controller.

    The SimpleHandlerMapping maps your controller to a specific URL.

  5. Step 5: Done

    You're now ready to deploy a Spring MVC-based web application using the Veriplace API.

  • < back to all tutorials

Developers

  • Developer Terms of Service
  • Privacy Policy
  • Content Requirements
  • Trademark Schedule
  • Forum

End Users

  • Terms of Service
  • Privacy Policy
  • Support

Follow Us

  • [icon] Facebook
    Facebook
  • [icon] Twitter
    Twitter
  • [icon] YouTube
    YouTube

Location Labs

info@location-labs.com

© 2010 Location Labs

All rights reserved.