我正在编写一个简单的CXF配置的RESTFULE服务。但是我一直遇到此错误"对于特定方法,找不到路径的子资源定位器"。虽然此方法正确映射了URL并能够获取参数,但是,始终丢弃此错误并返回404。
您可能已经忘记了在其余通话中指定请求类型,请检查您是否在通话中放置了@get,@post ..等适当的注释。
您需要共享完整的代码以获得更好的答案。
验证所有这些元素的声明如下:
package com.test.rs.sample;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import com.test.rs.dto.Student;
@Path("/student")
@Provider
public interface StudentService {
@GET
@Path("/get/{id}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Student getStudent(@PathParam("id")Long id);
@GET
@Path("/getAll/")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Student getAllStudents();
@POST
@Path("/add/")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response addStudent(Student student);
@PUT
@Path("/update/")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response updateStudent(Student student);
@DELETE
@Path("delete/{id}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Student deleteStudent(@PathParam("id")Long id);
}