我不能让重写处理程序在Jetty服务器6.1.24上工作。这是我在Scala中的例子:
val server = new Server(8080);
val contexts = new ContextHandlerCollection();
val rewriteHandler = new RewriteHandler();
rewriteHandler.setRewriteRequestURI(false);
rewriteHandler.setRewritePathInfo(false);
rewriteHandler.setOriginalPathAttribute("requestedPath")
rewriteHandler.addRewriteRule("/site1/test1","/site2/test2");
contexts.addHandler(rewriteHandler);
server.setHandler(contexts);
server.start();
.....
有什么想法吗?谢谢!
答案 0 :(得分:0)
RewriteHandler必须包装服务器处理程序。尝试替换:
contexts.addHandler(rewriteHandler);
使用:
rewriteHandler.setHandler(contexts);