2016-04-03 53 views
0

我用的球衣寫了JAX-RS服務和一流如下,請求的資源不可用JAX-RS服務

我要定義下面這個網址,

一通過傳遞參數,以獲得該報告

http://localhost:8085/DiginReport/rs/Reports/getreport/ {測試1:值,TEST2:值}

一啓動發動機:

http://localhost:8085/DiginReport/rs/Reports/start

@Path("Reports") 
public class ReportService { 

    @GET 
    @Path("/getreport}/{parameters}") 
    @Produces(MediaType.TEXT_PLAIN) 
    public Response getReport(@PathParam("reportName") String reportName,@PathParam("parameters") String parameters) throws KettleXMLException, KettleMissingPluginsException, JSONException, UnknownParamException { 
     JSONArray jsonarr; 
     return Response.status(200).entity("ok").build(); 
    } 


    @GET 
    @Path("{start}") 
    @Produces(MediaType.TEXT_PLAIN) 
    public Response startEngine(@PathParam("start") String command) { 
     return Response.status(200).entity("ok").build(); 
    } 
} 

當我在URL類型此,它說資源暫無數據, http://localhost:8085/DiginReport/rs/Reports/start

+1

'@Path(「/ getreport}/{parameters}」)'是否正確,因爲'getReports'有一個traling'}'? –

+0

它需要如何改變? – Sajeetharan

+0

它應該是'@Path(「/ getreport/{parameters}」)' –

回答

0

試試下面的代碼。

我也會考慮以下幾點:

傳遞JSON數據爲application/json,而不是字符串作爲路徑參數(請注意,你需要逃避

使用另一種方法比GET啓動發動機(例如, POST),因爲GET只應該用於對URL,而不是startgetreports中檢索數據。

使用資源。

@Path("Reports") 
public class ReportService { 

    @GET 
    @Path("/getreport/{parameters}") 
    @Produces(MediaType.TEXT_PLAIN) 
    public Response getReport(@PathParam("parameters") String parameters) throws KettleXMLException, KettleMissingPluginsException, JSONException, UnknownParamException { 
     JSONArray jsonarr; 
     return Response.status(200).entity("ok").build(); 
    } 


    @GET 
    @Path("/start") 
    @Produces(MediaType.TEXT_PLAIN) 
    public Response startEngine() { 
     return Response.status(200).entity("ok").build(); 
    } 
} 
+0

當我作爲獨立應用部署時,它已經修復。 – Sajeetharan

相關問題