Hi Mark,

If you want to prevent the matching of subpath by your resource, you need to
change the matching mode of your router or for the specific route. See:
 - Router#setDefaultMatchingMode()
 - Route/TemplateRoute#setMatchingMode()
 - Template#MODE_EQUALS

Regarding the failing content negotiation, I would suggest to try again with
a recent snapshot (post 2009-06-12) or with SVN trunk. If it still fails,
please send us a more complete code snippet of your resource.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

-----Message d'origine-----
De : [email protected] [mailto:[email protected]] 
Envoyé : vendredi 12 juin 2009 18:33
À : [email protected]
Objet : RE: Re: How goes content negotiation work?

I'm still having trouble with this myself.  Trying to serve both JSON and
XML representations of a resource that is called "world".

Here is what happens for 4 different test cases:

http://localhost:8080/world.xml

Fails!  I get this response:

The resource identified by the request is only capable of generating
response entities which have content characteristics not acceptable
according to the accept headers sent in the request

http://localhost:8080/world.xml/

works!  I get an xml representation of the resource.  I didn't mean to try
this (I added the '/' by mistake) and then was surprised when this worked.
I tried removing the '/' and it still fails.

http://localhost:8080/world.json

works as intended

http://localhost:8080/world.json/

gives me the xml representation


So I get that the '/' shouldn't be there at all (as I said, I put it there
by accident) but it would be nice if it behaved the same as the case with
the slash - is this easy to do?

More importantly, any idea why '.json' works but '.xml' doesn't?  I've tried
adding both 'MediaType.APPLICATION_XML' and 'MediaType.APPLICATION_ALL_XML'
(though not at the same time) and still have no luck.

Any ideas?  

Thanks,
T

P.S.  Here is some code:

        protected void doInit() throws ResourceException {
                
                Map<Method, Object> variants = getVariants();
                
                
                List<Variant> getVariants = new ArrayList<Variant>();
                getVariants.add(new Variant(MediaType.APPLICATION_JSON));
                getVariants.add(new Variant(MediaType.APPLICATION_XML));
                
                variants.put(Method.GET, getVariants);
                setVariants(variants);
        }

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=23616
79

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2362580

Reply via email to