我想找到一个解决方案,为相同的资源使用两个路由。
例如,我是一名资源客户,我想对"/customer“和”/ CustomerResource /“使用相同的资源,并添加一个尾部斜杠。
你对此有什么建议吗?
致以敬意,
编辑:我覆盖了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);
}
}发布于 2013-02-07 15:25:56
可以在两个不同的路由下附加相同的资源类:
router.attach("/customer",CustomerServerResource.class);
router.attach("/customer/",CustomerServerResource.class);
https://stackoverflow.com/questions/14727780
复制相似问题