Très particulier: HTTP Status 405 - Méthode non autorisée

[à l'aide d'Apache Tomcat/7.0.27]

Il semble que je ne reçois cette erreur

  • (HTTP Statut De 405 method not Allowed)

quand j'essaie de faire un RESTE de demander directement à partir du navigateur.

E. g par collage à présent dans la barre d'adresse :

http://localhost:8080/restExample/rest/catalog/video/14951/hello

Quand je lance mon client de test Main.java tout fonctionne bien.

Toutes les idées pour lesquelles il ne me laissera pas exécuter un REPOS à travers le navigateur?

Côté Client:

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);
    }

Côté serveur:

@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");
    }
}

source d'informationauteur Fabii