我尝试配置 jetty 重写规则。我使用了此处示例中的代码:http://www.eclipse.org/jetty/documentation/current/jetty-handlers.html#d0e10798 但是当我尝试运行它时我得到了:
2013-09-29 18:05:48.256:WARN:oejx.XmlConfiguration:main: Config error at <Set name="replacement">/redirected</Set> java.lang.NoSuchMethodException: class org.eclipse.jetty.rewrite.handler.RedirectPatternRule.setReplacement(class java.lang.String) in file:/opt/jetty/etc/jetty-rewrite.xml
2013-09-29 18:05:48.261:WARN:oejx.XmlConfiguration:main: Config error at <Call name="addRule">|<Arg>|<New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">|<Set name="pattern">/redirect/*</Set>|<Set name="replacement">/redirected</Set>|</New>|</Arg>|</Call> java.lang.NoSuchMethodException: class org.eclipse.jetty.rewrite.handler.RedirectPatternRule.setReplacement(class java.lang.String) in file:/opt/jetty/etc/jetty-rewrite.xml
2013-09-29 18:05:48.262:WARN:oejx.XmlConfiguration:main: Config error at <New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">|<Set name="rewriteRequestURI">true</Set>|<Set name="rewritePathInfo">false</Set>|<Set name="originalPathAttribute">requestedPath</Set>| ||<Call name="addRule">|<Arg>|<New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">|<Set name="pattern">/redirect/*</Set>|<Set name="replacement">/redirected</Set>|</New>|</Arg>|</Call>| ||<Call name="addRule">|<Arg>|<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">|<Set name="pattern">/some/old/context</Set>|<Set name="replacement">/some/new/context</Set>|</New>| </Arg>| </Call>| | | <Call name="addRule">| <Arg>| <New
ETC。
答案1
改变
Set name="replacement"
到
Set name="location"
RedirectPatternRule
在配置时jetty-rewrite.xml
,就像在旧码头网站上一样。
对我来说它有效(Jetty 9.1.0)。