2014-02-07 47 views
0

我正在編寫一個簡單的cxf配置的寧靜服務。但是我一直在收到這個錯誤「找不到路徑/的子資源定位器」。雖然此方法正確映射了url並能夠獲取參數,但是,始終會拋出此錯誤並返回404.找不到路徑的子資源定位器/

+1

我們如何理解你的問題?代碼請............... –

回答

1

您需要分享您的完整代碼以獲得更好的答案。

確認所有這些元素的聲明妥善象下面這樣:

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); 
} 
10

您可能忘記在指定其餘呼叫請求類型,檢查你已經把適當的註解像@Get,@Post ..你是否打電話。

+1

這是一個比評論更多的評論 –