【发布时间】:2013-02-06 11:19:48
【问题描述】:
我想找到一种解决方案,将 2 条路线用于同一资源。
例如,我是一个资源 CustomerResource,我想将同一资源用于“/customer”和“/customer/”,并添加尾部斜杠。
您对此有什么建议吗?
问候,
编辑:我重写 SpringBeanRouter 以发布带有和不带有斜杠路由的资源:
public class MySpringBeanRouter extends SpringBeanRouter {
@Override
public TemplateRoute attach(String pathTemplate, Restlet target) {
if(pathTemplate != null && pathTemplate.endsWith("/"))
super.attach(pathTemplate.substring(0, pathTemplate.length() - 1), target);
return super.attach(pathTemplate, target);
}
}
【问题讨论】: