Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java jersey webservices 404错误_Java_Web Services_Rest_Jersey - Fatal编程技术网

Java jersey webservices 404错误

Java jersey webservices 404错误,java,web-services,rest,jersey,Java,Web Services,Rest,Jersey,我知道有很多类似的问题有很多答案,但没有一个能真正帮助我解决这个问题。这就是我决定发布一个新问题的原因。因此,基本上我使用的是带有角度前端的jersey。当我执行url时,它显示404错误“请求的资源不可用”。下面是我的web.xml index.html index.jsp Jersey Web应用程序 org.glassfish.jersey.servlet.ServletContainer jersey.config.server.provider.packages com.abc.re

我知道有很多类似的问题有很多答案,但没有一个能真正帮助我解决这个问题。这就是我决定发布一个新问题的原因。因此,基本上我使用的是带有角度前端的jersey。当我执行url时,它显示404错误“请求的资源不可用”。下面是我的web.xml


index.html
index.jsp
Jersey Web应用程序
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.abc.rest
1.
Jersey Web应用程序
/休息/*
和网络服务:

package com.abc.rest;
导入java.util.Iterator;
导入java.util.List;
导入javax.ws.rs.Consumes;
导入javax.ws.rs.GET;
导入javax.ws.rs.POST;
导入javax.ws.rs.Path;
导入javax.ws.rs.products;
导入javax.ws.rs.core.MediaType;
导入com.abc.dao.AddLeaveDao;
导入com.abc.dao.LeaveDao;
导入com.abc.entity.LeaveBalance;
//导入com.abc.entity.Love;
导入com.abc.entity.LeaveDetails;
@路径(“/离开”)
公开课离场{
@得到
@路径(“列表”)
@产生({“应用程序/json”})
公开名单(){
List l=new leveldao().getAllLeves();
返回l;
}
@职位
@路径(“创建”)
@使用({MediaType.APPLICATION_JSON})
@产生({“应用程序/json”})
创建公共字符串(LEVEDETAILS ld){
新的AddLeaveDao().addDetails(ld);
System.out.println(“返回此处”);
返回“{}”;
}
}
项目结构:


请帮助我解决此问题

在您的资源中,您的路径映射应以“/”作为前缀

@Path(“/list”)
@产生({“应用程序/json”})
公开名单(){
列表l=new LeaveDao().getAllLeaves();
返回l;
}

更改后,如果您使用的是maven,请执行mvn clean install更新您的资源,停止在JS/HTML和浏览器兼容语言以外的其他语言中使用代码段你确定你的服务器正在运行吗?是的,我正在运行代码。我必须重构代码并重命名一些包和变量。从那时起它停止工作…一切似乎都很好..不明白我哪里出错了你怎么了精确重构?创建新包并将文件移到那里。重命名WS-class,将@path从blog更改为list,用新包名和新url模式更新web.xml。如果使用maven,请尝试执行mvn clean安装
@Path("/list")
@Produces({ "application/json" })
public List<LeaveBalance> list() {
    List l= new LeaveDao().getAllLeaves();
    return l;
}