【发布时间】:2018-09-07 09:43:30
【问题描述】:
我有这个客户端 angular 1.5 代码
var getGroupForUser = function () {
var deferred = $q.defer();
$http.get(env.domain+'/Voices/authorize').then(
function successCallback(response) {
// self.isAdOps = response.data.;
deferred.resolve(response.data);
}, function errorCallback(response) {
console.log(response.data.errorMsg);
self.isAdOps = true;
deferred.reject("data: "+response.data+" code:"+response.status+" "+response.statusText+", please look at the web console");
});
return deferred.promise;
};
和服务器上的这个球衣java代码:
@Path("/Voices")
public class VoicesOperation {
@Path("/search")
@GET
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public List<VoiceUi> search(@QueryParam("q") String searchTerm) throws Exception {...
}
@Path("/authorize")
@GET
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public String authorize() {
logger.info("in voicesOperation - authorization");
logger.error("checking error log ==== in voicesOperation - authorization");
但是我在服务器中遇到错误:
javax.ws.rs.NotFoundException: HTTP 404 Not Found
我错过了什么?
【问题讨论】:
-
您使用什么网址进行测试?
-
env.domain+'/Voices/authorize'->http://localhost:8860/Elton/Voices/authorize -
这个网址是否在浏览器中返回值?你确定这正是 Angular 客户端使用的 url 吗?
-
您是否通过互联网浏览器直接使用
http://localhost:8860/Elton/Voices/authorize进行检查?同时打印env.domain+'/Voices/authorize'并检查url 是否正确。我相信/Elton你已经在 web.xml 文件中声明了 -
@AbhijitPritam 我在浏览器中尝试了相同的
http://localhost:8860/Elton/Voices/authorize和相同的异常,但是当我尝试http://localhost:8860/Elton/Voices/seach时它工作正常。
标签: java angularjs http web jersey