i'm new in angularjs , jersey , need little in writing helloworld rest application...
here jersey
@path("/helloworld") public class helloworldresource { @get @produces(mediatype.text_plain) public string sayhello(){ return "hello jersey world"; } } and here controller client angularjs
angular.module('myapp', ['serverapp']); angular.module('serverapp',['ngresource']).factory('servercom', function($resource){ return $resource('http://192.168.2.60\\:8080/restexample/helloworld/', {}, {query: {method:'get', params:{}, isarray:false}}); }); function mycontroller($scope, servercom){ $scope.temp = servercom.get(); $scope.text = $scope.temp.name; } now problem when access rest service through browser returns string , ok...but when try access through angularjs following message in jersey :
com.sun.jersey.server.wadl.generators.wadlgeneratorjaxbgrammargenerator attachtypes info: couldn't find jax-b element class java.lang.string
so whats wrong jersey(or angular) code?
angularjs expecting json returned resource returns simple string might problem.
in code above, try return simple json resource method, like
return "{\"name\":\"hello jersey world\"}"; and add "application/json" producible media types
@produces({mediatype.application_json, mediatype.text_plain}) however, i'd recommend switching jersey 2.0 (see user guide) , take @ bean validation example uses angularjs on front-end.
Comments
Post a Comment