在你减去这个问题之前,你应该知道我搜索了解决方案而没有找到它.
我想通过rest端点返回String:
@GET @Path("/getMyString") @Produces({ MediaType.APPLICATION_JSON }) public Response getId() { String s = "this is my string"; (...) return Response.ok(s).build(); }
但是在视图中我收到了char数组(结果是firebug):
Resource { 0="t", 1="h", 2="i", more...}
在前面我使用角度资源,如:
blablaResources.factory('AngularApp', [ '$resource', function($resource) { return $resource(contextPath + '/.rest/v1/someService', {}, { (... other methods ...) getString : { method : 'GET', url : contextPath + '/.rest/v1/someService/getMyString' } }); } ]);
是否有任何String或注释的包装类来发送它:
Resource { value = "this is my string" }
或者只是正常
"this is my string"
感谢任何建设性的回应:)
尝试使用
@Produces({ MediaType.TEXT_PLAIN })