在你忽略这个问题之前,你应该知道我搜索了解决方案但没有找到。
我想通过 rest 端点返回字符串:
@GET
@Path("/getMyString")
@Produces({ MediaType.APPLICATION_JSON })
public Response getId() {
String s = "this is my string";
(...)
return Response.ok(s).build();
}
但是在 View 中我收到了 char 数组(导致 Firebug ):
Resource { 0="t", 1="h", 2="i", more...}
在前面我使用像这样的 Angular 资源:
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 })
关于java - 使用 REST 端点返回字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24424305/