Spring MVC AngularJS RESTFul Service example

Spring MVC AngularJS RESTFul Service example

In this demo we will develop Spring MVC AngularJS RESTFul Service complete application where we will use Spring MVC as RESTFul service and on the client side AngularJS as consumer of the service which will make “HTTP” call to service and process the response data received from the service.

Summary logic of this tutorial:

  • service.js making http call to service:

  • serviceController.js making call to the service and store data in the scope:

 

Let’s see detail example step by step 

  • Create project name: SpringMVCAngularJSService
  • Final project structure:

Spring MVC AngularJS RESTFul Service example

  • pom.xml:

  • web.xml:

  • dispatcher-servlet.xml:

  • log4j.xml to write log data on console and file:

  • messages_en.properties as resource bundle use as static data holder for the application:

  • AngularJSService.jsp

  • serviceController.js:

  • service.js:

  • SpringMVCController.java:

  • Now lets run this application (We are using tomcat server with eclipse to run this if you are not sure how to configure and run tomcat with eclipse please follow this tutorial). To run: Right click project –> Run As –> Run on Server where you will see below page:

Spring MVC AngularJS RESTFul Service example

  • Click “Get JSON data from server” button you will see below data:

Spring MVC AngularJS RESTFul Service example

  • That’s it we have created Spring MVC AngularJS RESTFul Service example and ran successfully.
  • For more information about Spring MVC RESTFul service please visit this tutorial
  • For AngularJS visit this tutorial

download Download Project: SpringMVCAngularJSRESTFulService

One thought on “Spring MVC AngularJS RESTFul Service example

  1. Hello sir,

    Spring MVC AngularJS RESTFul Service example

    When I import into Eclipse STS, and run. then I clicked the button, but the error 0 occured coming

    Raw data received form server:

    Iterate and align data received form server:
    data not coming

    please sir give me good working

    regards
    arun

Leave a Reply

Your email address will not be published. Required fields are marked *