Home:ALL Converter>Error in returning java object to javascript

Error in returning java object to javascript

Ask Time:2016-07-17T20:39:02         Author:Ashish Agrawal

Json Formatter

I am returning a java object to client(javascript) page, i.e. converting java object to JSON object but am facing no converter found for return value error. I have added all spring jars and jackson-all-xxx.jar. The below is the method that gets called from a html page using $http.get('url').

@RequestMapping(value="/springAngularJS",method=RequestMethod.GET)               
public @ResponseBody Person  getPerson() {  
System.out.println("111111111");  
Person person = new Person();
    person.setFirstName("Java");
    person.setLastName("Honk");
    return person;
    }

My html page: (posting only JS part) var app = angular.module('myApp', []);

function MyController($scope, $http){

    $scope.getPersonDataFromServer = function() {           
        $http.get("springAngularJS").
        success(function(data, status, headers, config) {
            $scope.person = data;
        }).
        error(function(data, status, headers, config) {
          // called asynchronously if an error occurs
          // or server returns response with an error status.
        });

    };
};

Any help to resolve this would be appreciated.. I am a beginner..:)

Author:Ashish Agrawal,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/38421291/error-in-returning-java-object-to-javascript
yy