Skip to Main Content
Spring MVC Beginner's Guide
book

Spring MVC Beginner's Guide

by Amuthan Ganeshan
June 2014
Beginner to intermediate content levelBeginner to intermediate
304 pages
7h 25m
English
Packt Publishing
Content preview from Spring MVC Beginner's Guide

Time for action – consuming REST web services via Ajax

In order to consume Rest web services via Ajax, perform the following steps:

  1. Add a JavaScript file named controllers.js under the directory /src/main/webapp/resources/js/; then, add the following code snippets to it and save it:
    var cartApp = angular.module('cartApp', []); cartApp.controller('cartCtrl', function ($scope, $http) { $scope.refreshCart = function(cartId) { $http.get('/webstore/rest/cart/'+$scope.cartId) .success(function(data) { $scope.cart = data; }); }; $scope.clearCart = function() { $http.delete('/webstore/rest/cart/'+$scope.cartId) .success($scope.refreshCart($scope.cartId)); }; $scope.initCartId = function(cartId) { $scope.cartId=cartId; $scope.refreshCart($scope.cartId); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Spring MVC Beginner's Guide - Second Edition

Spring MVC Beginner's Guide - Second Edition

Amuthan Ganeshan
Spring MVC: Designing Real-World Web Applications

Spring MVC: Designing Real-World Web Applications

Shameer Kunjumohamed, Hamidreza Sattari, Alex Bretet, Geoffroy Warin

Publisher Resources

ISBN: 9781783284870Supplemental Content