當我在tomcat服務器上運行我的web應用程序時出現此錯誤。我的REST程序出錯
這是我的代碼
@Path("/robot")
public class Robot {
@POST
//@Path("/add")
@Consumes(MediaType.APPLICATION_JSON)
//@Produces(MediaType.APPLICATION_JSON)
public Response displayTemperature(ProcessModel tempData){
System.out.println(" \n\n ");
System.out.println("|The temp is : "+ tempData.getTemperature() +" "+ " Robot deployment time is " + " "+tempData.getTime() +" |");
Client client = Client.create();
WebResource webResource2 = client.resource("http://localhost:8080/RESTServer/rest/hello/run");
ClientResponse response2 = webResource2.get(ClientResponse.class);
if (response2.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response2.getStatus());
}
String output2 = response2.getEntity(String.class);
System.out.println("\n<<<============ POSTING command to Robot Info Model ============>>>");
System.out.println(output2);
return Response.ok(200).header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS").entity("POSTED").build();
}
}
Jersey客戶端jar文件添加到類路徑 – Reimeus
我已經添加澤西Jar文件到項目中。但它仍然顯示了同樣的錯誤:/ – Agnnn
沒有的罐子在項目文件夾中。如何添加到tomcar/app服務器? – Agnnn