请求的资源不可用jax-rs服务 [英] Requested resource not available jax-rs service
问题描述
我使用jersey编写了一个jax-rs服务,其类如下,
I wrote a jax-rs service using jersey, and the class is as follows,
我想这样定义以下网址,
I want to define the url for the following like this,
通过传递参数来获取报告
http://localhost:8085/DiginReport/rs/Reports/getreport/ {test1:value,test2:value}
http://localhost:8085/DiginReport/rs/Reports/getreport/{test1:value,test2:value}
一个启动引擎:
@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
When i type this in url , it says resource not avaliable, http://localhost:8085/DiginReport/rs/Reports/start
推荐答案
尝试以下代码.
我还将考虑以下事项:
将Json数据作为application/json
而不是字符串作为路径参数传递(请注意,您需要转义.
Pass Json data as application/json
instead of string as path parameter (note that you need to escape.
使用GET
以外的其他方法来启动引擎(例如POST
),因为get仅应用于检索数据.
Use another method than GET
to start the engine (e.g. POST
), since get should be only used to retrieve data.
使用URL中的资源而不是start
或getreports
.
Use resources within the URL instead of start
or getreports
.
@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();
}
}
这篇关于请求的资源不可用jax-rs服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!