【问题标题】:javax.ws.rs.NotFoundException: HTTP 404 Not Found angular 1.5javax.ws.rs.NotFoundException: HTTP 404 Not Found angular 1.5
【发布时间】: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


【解决方案1】:

只需在下面修改您的喜欢并尝试:-

public String authorize(@Context UriInfo info) {
    .
    .
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多