我正在使用VRaptor来实现一个web服务。我正在寻找一种向URI添加服务前缀(例如/v1/*)的方法。我想在全球范围内完成这项工作,而不是使用@Path("/v1/")。
如何使用这个框架和Tomcat来实现呢?是否可以使用webxml (servlet映射?)。
提前谢谢。
发布于 2014-10-25 00:30:34
另一种方法是专门化VRaptor的PathAnnotationRoutesParser,即:
@Alternative
@Priority(Interceptor.Priority.LIBRARY_BEFORE+10)
public class CustomRouterParser extends PathAnnotationRoutesParser {
protected CustomRouterParser() {
this(null, null);
}
@Inject
public CustomRouterParser(Router router, Environment environment) {
super(router);
this.environment = environment;
}
@Override
protected String[] getURIsFor(Method javaMethod, Class<?> type) {
return "CUSTOM-PREFIX" + super.getURIsFor(javaMethod, type);
}
}你可以在http://www.vraptor.org/en/docs/components/#customizing-vraptor上看到更多的例子。最好的
https://stackoverflow.com/questions/25533763
复制相似问题