gpt4 book ai didi

html - Tomcat 基本 URL 重定向

转载 作者:技术小花猫 更新时间:2023-10-29 11:30:59 25 4
gpt4 key购买 nike

使用 tomcat,如何获取对 http://www.mydomain.example 的请求以重定向到 http://www.mydomain.example/somethingelse/index.jsp ?我什至还没有设法从 http://mydomain.example 中获取要显示的 index.html。

最佳答案

您可以这样做:如果您的 tomcat 安装是默认的并且您没有进行任何更改,那么默认的 war 将是 ROOT.war。因此,每当您调用 http://yourserver.example.com/ 时,它都会调用您的 index.htmlindex.jsp默认 WAR 文件。在 webapp/ROOT 文件夹中进行以下更改以将请求重定向到 http://yourserver.example.com/somewhere/else:

  1. 打开webapp/ROOT/WEB-INF/web.xml,删除路径为 /index.html/index.jsp 的任何 servlet 映射,并保存。

  2. 删除 webapp/ROOT/index.html(如果存在)。

  3. 使用以下内容创建文件 webapp/ROOT/index.jsp:

    <% response.sendRedirect("/some/where"); %>

    或者如果你想定向到不同的服务器,

    <% response.sendRedirect("http://otherserver.example.com/some/where"); %>

就是这样。

关于html - Tomcat 基本 URL 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1363605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com