Java 请求的资源不可用jax rs服务
我使用jersey编写了一个jax rs服务,类如下所示 我想像这样定义以下内容的url 通过传递参数获取报告的一种方法 {test1:value,test2:value} 一个启动引擎: 当我在url中输入这个时,它说资源不可用,Java 请求的资源不可用jax rs服务,java,web-services,rest,jax-rs,Java,Web Services,Rest,Jax Rs,我使用jersey编写了一个jax rs服务,类如下所示 我想像这样定义以下内容的url 通过传递参数获取报告的一种方法 {test1:value,test2:value} 一个启动引擎: 当我在url中输入这个时,它说资源不可用, 请尝试以下代码 我也会考虑以下事项: 将Json数据作为application/Json而不是字符串作为路径参数传递(请注意,您需要转义) 使用GET以外的其他方法启动引擎(例如POST),因为GET应仅用于检索数据 使用URL中的资源,而不是start或getr
请尝试以下代码 我也会考虑以下事项: 将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();
}
}
@Path(“/getreport}/{parameters}”)
这是正确的,因为getReports
有一个traling}
?它需要如何更改?应该是@Path(/getreport/{parameters}”)
好的,我会更改,为什么其他url不起作用?你可以像@Path(/command/{start})那样尝试吗
并使用http://localhost:8085/DiginReport/rs/Reports/command/start
当我作为独立应用程序部署时,它已修复。
@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();
}
}