使用tomcat,如何获取请求http://www.mydomain.example
重定向到http://www.mydomain.example/somethingelse/index.jsp
?我什至没有设法获得要显示的index.htmlhttp://mydomain.example
.
你可以这样做:
如果你的tomcat安装是默认安装并且你没有做任何更改,那么默认的war将是ROOT.war
。因此,每当你打电话时http://yourserver.example.com/
,它会调用index.html
or index.jsp
您的默认 WAR 文件。在您的中进行以下更改webapp/ROOT
用于将请求重定向到的文件夹http://yourserver.example.com/somewhere/else
:
Open webapp/ROOT/WEB-INF/web.xml
,
删除所有 servlet 与路径的映射/index.html
or /index.jsp
,
并保存。
Remove webapp/ROOT/index.html
,如果存在的话。
-
创建文件webapp/ROOT/index.jsp
这行内容:
<% response.sendRedirect("/some/where"); %>
或者如果您想定向到不同的服务器,
<% response.sendRedirect("http://otherserver.example.com/some/where"); %>
就是这样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)