请求的资源不可用 jax-rs 服务
Requested resource not available jax-rs service
我用jersey写了一个jax-rs服务,class如下,
我想为下面这样定义 url,
一个通过传递参数获取报告
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
试试下面的代码。
我还会考虑以下事项:
将Json数据作为application/json
而不是字符串作为路径参数传递(注意需要转义。
使用不同于 GET
的其他方法启动引擎(例如 POST
),因为 get 应该只用于检索数据。
使用 URL 内的资源,而不是 start
或 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();
}
}
我用jersey写了一个jax-rs服务,class如下,
我想为下面这样定义 url,
一个通过传递参数获取报告
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
试试下面的代码。
我还会考虑以下事项:
将Json数据作为application/json
而不是字符串作为路径参数传递(注意需要转义。
使用不同于 GET
的其他方法启动引擎(例如 POST
),因为 get 应该只用于检索数据。
使用 URL 内的资源,而不是 start
或 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();
}
}