Home Ask Login Register

Developers Planet

Your answer is one click away!

user3802040 February 2016

Spring dont see angular

I am trying adapt my app to use angular, but currently it seems that spring cannot see/communicate with angular. Here is what i have :


public class IndexController {
 @RequestMapping(value = "/login", method = RequestMethod.GET, produces = {"application/json"})
 public @ResponseBody Map<String, Object> getIndexPage() {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("id", UUID.randomUUID().toString());
    model.put("content", "Hello Worl123321");
    return model;


<!doctype html>

      <!--<link href="css/angular-bootstrap.css" rel="stylesheet">
      <link rel="stylesheet" href="css/app.css"/>-->
      <style type="text/css">
        .ng-cloak {
            display: none !important;
      <script src="js/angular-bootstrap.js" type="text/javascript"></script>>
      <script src="app/app.js"></script>
      <script src="app/listView/listView.js"></script>

  <body ng-app="myApp">
      <!-- Application content -->
      <div ng-include="'app/app.html'"></div>



<div class="container">
    <div ng-controller="appCtrl" ng-cloak class="ng-cloak">


angular.module('myApp', [])
    .controller('appCtrl', function($scope, $http) {
        $http.get('/login/').success(function(data) {
            $scope.greeting = data;

I just get an output like this :

{"id":"01cdab29-e0ce-45ee-abb9-64b2640859ca","content":"Hello Worl123321"}


Walfrat February 2016

What do you use to serialise as JSON ?

This is maybe because of the Map<> that you have an extra field 'content' between your object and your data try.

 $scope.greeting = data.content;

I've already heard of some problem like this with Jackson adding a "content" though it was for a hibernate problem.

If you don't want that extra field : create a wrapper class having an id and content field and use it.

Post Status

Asked in February 2016
Viewed 2,484 times
Voted 7
Answered 1 times


Leave an answer

Quote of the day: live life