Here is a class which fixes the issue. Probably a better solution would be
to change the Route class so that if the remainingPart is "" it sets it to
"/" before doing the regex matching. On a related note is it possible to
force exact matching so that say /apps would be mapped but not /apps/xyz?

public class RootSpringBeanRouter extends SpringBeanRouter {
  @Override
  public void handle(Request request, Response response) {
    Reference resourceRef = request.getResourceRef();
    if (resourceRef.getRemainingPart().equals("")) {
      resourceRef.addSegment("");
    }
    super.handle(request, response);
  }
}


On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin <mail-li...@revolsys.com>wrote:

> In my project I am deploying an application as a war file. The root of the
> web application /* is mapped to the RestletFrameworkServlet so that all
> handling is performed by Restlet.
>
>   <servlet>
>     <servlet-name>bpf</servlet-name>
>
> <servlet-class>com.noelios.restlet.ext.spring.RestletFrameworkServlet</servlet-class>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>bpf</servlet-name>
>     <url-pattern>/*</url-pattern>
>   </servlet-mapping>
>
> The root restlet is a SpringBeanRouter and I have a mapping for / to a
> resource as shown below.
>
>  <bean id="root" class="org.restlet.ext.spring.SpringBeanRouter" />
>
>   <bean
>     name="/"
>     id="rootResource"
>     scope="prototype"
>     class="myResourceClass"
>   />
>
> The war is deployed to /ws on my server.
>
> If I access /ws I get an Restlet status page error saying "The server has
> not found anything matching the request URI" but if I use /ws/ it works
> correctly.
>
> I tried mapping to "" to see if that would work and it gives the same
> behaviour.
>
> Is it possible to modify the router so that the root resource does not need
> the trailing slash?
>
> Cheers,
> Paul
>

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

Reply via email to