`
weifly
  • 浏览: 235930 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

jetty-如何重定向或移动context

 
阅读更多

jetty中文文档:www.jettycn.com

 

MovedContextHandler

Jetty >> howto >> MovedContextHandler

如何重定向或移动context

如果改变了一个context的上下文路径和/或虚拟主机,你可以使用MovedContextHandler 来重新定位或重定向这个context。

你可以配置它为永久的,从旧的url重定向到新的url,在这种情况下,Jetty将发送301的Http状态码和新的url给浏览器。或者,你可以配置它为非永久的,在这种情况下,Jetty将发送302的Http状态码和新的url给浏览器。

此外,就像配置其他context一样,你可以配置一个虚拟主机列表,这意味着,这个context只响应列表中主机名相关的请求。

假设我们有一个部署在/foo上的context,但现在我们想把这个context部署在根上下文(/)上。首先,我们在Jetty上重新配置和部署我们的context。接下来,我们需要一种方法来重定向所有浏览器中的/foo书签到新的路径。我们在$JETTY_HOME/contexts文件夹中创建一个新的context xml文件,并配置MovedContextHandler来做重定向工作,把"/foo"重定向到"/"。

下面是一个例子。我们选择做一个永久的重定向,在重定向的同时,保留pathinfo和查询字符串(query strings):

 

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.server.handler.MovedContextHandler">
  <Set name="contextPath">/foo</Set>
  <Set name="newContextURL">/</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>

  <Set name="virtualHosts">
    <Array type="String">
          <Item>209.235.245.73</Item>
          <Item>127.0.0.73</Item>
          <Item>acme.org</Item>
          <Item>www.acme.org</Item>
          <Item>server.acme.org</Item>
    </Array>
  </Set>

</Configure>

分享到:
评论

相关推荐

    eclipse jetty插件run-jetty-run-1.3.3

    eclipse jetty插件,从...下载run-jetty-run.zip文件,解压后再编写个links文件丢到eclipse的dropins目录下即可,省去了使用eclipse update方式安装的麻烦。 link文件样例如: path=d:\\eclipse_plugins\\run-jetty-run

    jetty-util-6.1.26-API文档-中英对照版.zip

    赠送jar包:jetty-util-6.1.26.jar; 赠送原API文档:jetty-util-6.1.26-javadoc.jar; 赠送源代码:jetty-util-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-util-6.1.26.pom; 包含翻译后的API文档:jetty-...

    jetty-http-9.4.11.v20180605-API文档-中英对照版.zip

    赠送jar包:jetty-http-9.4.11.v20180605.jar; 赠送原API文档:jetty-http-9.4.11.v20180605-javadoc.jar; 赠送源代码:jetty-http-9.4.11.v20180605-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty相关的全部jar包

    jetty-security-9.4.8.v20171121.jar,jetty-io-9.4.8.v20171121.jar,jetty-continuation-9.4.8.v20171121.jar,jetty-client-9.4.8.v20171121.jar,jetty-jmx-9.4.8.v20171121.jar,jetty-plus-9.4.8.v20171121....

    run-jetty-run 1.3.5eclipse插件包

    run-jetty-run 1.3.5(Nightly) 在eclipse 4.5.2中安装jetty插件,然后提取plugins和features目录中的相关文件,打包做成可用link方式安装,省去更换eclipse版本时需要重新下载的问题。 安装方法为新加一个run-jetty...

    jetty-all-9.4.47.v20220610-uber.jar

    jetty-all-9.4.47.v20220610-uber.jar

    jetty-server-8.1.8-API文档-中英对照版.zip

    赠送jar包:jetty-server-8.1.8.jar; 赠送原API文档:jetty-server-8.1.8-javadoc.jar; 赠送源代码:jetty-server-8.1.8-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8.pom; 包含翻译后的API文档:...

    jetty-security-9.3.19.v20170502-API文档-中英对照版.zip

    赠送jar包:jetty-security-9.3.19.v20170502.jar; 赠送原API文档:jetty-security-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-security-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty-server-8.1.8.v20121106-API文档-中文版.zip

    赠送jar包:jetty-server-8.1.8.v20121106.jar; 赠送原API文档:jetty-server-8.1.8.v20121106-javadoc.jar; 赠送源代码:jetty-server-8.1.8.v20121106-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8...

    jetty-io-9.4.8.v20171121-API文档-中文版.zip

    赠送jar包:jetty-io-9.4.8.v20171121.jar; 赠送原API文档:jetty-io-9.4.8.v20171121-javadoc.jar; 赠送源代码:jetty-io-9.4.8.v20171121-sources.jar; 赠送Maven依赖信息文件:jetty-io-9.4.8.v20171121.pom;...

    jetty-webapp-9.3.19.v20170502-API文档-中文版.zip

    赠送jar包:jetty-webapp-9.3.19.v20170502.jar; 赠送原API文档:jetty-webapp-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-webapp-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-webapp-...

    jetty-util-6.1.26-API文档-中文版.zip

    赠送jar包:jetty-util-6.1.26.jar; 赠送原API文档:jetty-util-6.1.26-javadoc.jar; 赠送源代码:jetty-util-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-util-6.1.26.pom; 包含翻译后的API文档:jetty-...

    jetty-io-9.4.43.v20210629-API文档-中文版.zip

    赠送jar包:jetty-io-9.4.43.v20210629.jar; 赠送原API文档:jetty-io-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-io-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-io-9.4.43.v20210629....

    jetty-sslengine-6.1.26-API文档-中文版.zip

    赠送jar包:jetty-sslengine-6.1.26.jar; 赠送原API文档:jetty-sslengine-6.1.26-javadoc.jar; 赠送源代码:jetty-sslengine-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-sslengine-6.1.26.pom; 包含...

    jetty-util-9.4.43.v20210629-API文档-中文版.zip

    赠送jar包:jetty-util-9.4.43.v20210629.jar; 赠送原API文档:jetty-util-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-util-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-util-9.4.43.v...

    jetty-sslengine-6.1.26-API文档-中英对照版.zip

    赠送jar包:jetty-sslengine-6.1.26.jar; 赠送原API文档:jetty-sslengine-6.1.26-javadoc.jar; 赠送源代码:jetty-sslengine-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-sslengine-6.1.26.pom; 包含...

    jetty-server-8.1.8-API文档-中文版.zip

    赠送jar包:jetty-server-8.1.8.jar; 赠送原API文档:jetty-server-8.1.8-javadoc.jar; 赠送源代码:jetty-server-8.1.8-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8.pom; 包含翻译后的API文档:...

    jetty-client-9.4.43.v20210629-API文档-中文版.zip

    赠送jar包:jetty-client-9.4.43.v20210629.jar; 赠送原API文档:jetty-client-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-client-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-client-...

    jetty-6.1.26-API文档-中文版.zip

    赠送jar包:jetty-6.1.26.jar; 赠送原API文档:jetty-6.1.26-javadoc.jar; 赠送源代码:jetty-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-6.1.26.pom; 包含翻译后的API文档:jetty-6.1.26-javadoc-API...

    jetty-http-7.4.2.v20110526.jar

    jetty-http-7.4.2.v20110526.jar jetty-http 服务jar包

Global site tag (gtag.js) - Google Analytics