users@jersey.java.net

Re: [Jersey] letting /resource/ and /resource be the same

From: tarjei <tarjei_at_nu.no>
Date: Tue, 18 Aug 2009 15:38:54 +0200

Hi,

I'm using 1.1.0-ea. I tried upgrading to 1.1.1-ea as well with the same
result.

On 08/18/2009 03:16 PM, Paul Sandoz wrote:
> Hi,
>
> What is the value of the @Path ?

The setup is:

@Path("/")
//_at_ProduceMime("application/xml")
@Component("root")
class Root {
...
}

@Path("Filter")
@Produces("application/xml")
@Service("jersey.filterFrontend")
class Resource {
@GET
        public List<Filter> list() {}
}

I've tried adding @Path("/") and @Path("") to the list() method, but
without success.

Changing the class @Path from @Path("Filter") to @Path("Filter/") worked.

I guess that is what confused me. I thought that if I had @Path("/")
then that would be appended to the base path. At least the issue is
resolved.

Kind regards,
Tarjei



>
> Note the following:
>
> https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html#FEATURE_REDIRECT
>
> If true, and the path value of a |Path| annotation ends in a slash, the
> request URI path does not end in a '/' and would
> otherwise match the path value if it did, then the client is
> (temporarily) redirected to a new URI that is the request URI
> with a '/' appended to the the end of the path.
>
>
> What version of Jersey are you using?
>
> More recent versions of Jersey were modified so that, if redirect is
> false, URI paths of "/resource" and "/resource/" will match
> @Path("resource") and @Path("resource/").
>
> Paul.
>
> On Aug 18, 2009, at 3:03 PM, tarjei wrote:
>
>> Hi, I'm trying to make requests with a trailing slash match requests
>> without it.
>>
>> To do this, I've tried adding the following to my web.xml:
>> <servlet-name>Jersey Spring</servlet-name>
>> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
>> <init-param>
>> <param-name>com.sun.jersey.config.feature.Redirect</param-name>
>> <param-value>true</param-value>
>> </init-param>
>> <init-param>
>> <param-name>com.sun.jersey.config.feature.CanonicalizeURIPath</param-name>
>> <param-value>true</param-value>
>> </init-param>
>> <init-param>
>> <param-name>com.sun.jersey.config.feature.NormalizeURI</param-name>
>> <param-value>true</param-value>
>> </init-param>
>>
>> Still, when I try to visit /resource/ I get a 404 while /resource
>> returns the correct method.
>>
>> What can I do to match the same method to both URIs?
>>
>> Regards,
>> Tarjei
>> --
>> Tarjei Huse
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> <mailto:users-unsubscribe_at_jersey.dev.java.net>
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> <mailto:users-help_at_jersey.dev.java.net>
>>
>


-- 
Tarjei Huse
Mobil: 920 63 413