가 [아파치 톰캣/7.0.27이 사용]매우 독특한 : HTTP 상태 405 - 방법이 허용되지 않음 - 방법은
그것은 내가에만이 오류가 보인다
이- (는 HTTP는 상태 (405) 허용되지 않음)
브라우저에서 직접 REST 요청을하려고 할 때. 주소 표시 줄에이 붙여 넣기하여
예컨대 : 나는 내 테스트 클라이언트 Main.java를 실행하면
http://localhost:8080/restExample/rest/catalog/video/14951/hello
모든 것이 잘 작동합니다.
브라우저를 통해 REST를 실행하게하는 이유는 무엇입니까?
클라이언트 측 :
public class Main{
public static void main(String [] args){
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI(_package));
runPutRequest(service,"video/128/This is the content with the new description");
}
}
...
private static void runPutRequest(WebResource service,String path){
String response = service.path("rest/catalog/"+path).accept(MediaType.APPLICATION_XML).put(String.class);
System.out.println("Post Response :"+response);
}
서버 측 :
@PUT
@Path("/video/{video-id}/{short-descr}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_XML)
public Video updateVideo(@PathParam("video-id") int contentid,
@PathParam("short-descr") String descr)
{
//Video video = searchByContentId(contentid);
Video video = videoMap.get(contentid);
video.setDescription(descr);
videoMap.put(contentid,video);
if(videoMap.get(contentid) != null){
return videoMap.get(contentid);
}else{
throw new UnsupportedOperationException("NO object found");
}
}
대 놓으십시오 .... – esej