users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 18 Aug 2009 15:16:27 +0200

Hi,

What is the value of the @Path ?

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
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>