我一直在使用Java构建一个部署在Tomcat7中的REST Web服务;和HTML / AngularJS的客户端。
@GET
@Path("/hello")
@Produces("plain/text")
public Response hello(){
String hello="hello";
return Response.status(Status.OK).entity(hello).build();
}
服务器端的这个简单方法似乎在使用正确的URL(http://localhost:8080/some-path/hello)从浏览器调用时工作,并以纯文本形式发出hello。
在Tomcat日志文件中,Everthing似乎也是正确的。
但是,有了这段代码,
$http({
url: 'http://localhost:8080/some-path/hello',
method: 'GET'
}).then(
function (response){
$scope.passCheck = response.data;
},
function (response){
$scope.passCheck = response.status ;
}
);
我正在获得-1状态代码(始终执行第二个响应函数)。
有人可以帮我吗?
答案 0 :(得分:0)
整天工作后解决了。 问题是我没有将html文件与项目本身一起部署。我在项目中创建了相同的html文件,它工作正常。