gpt4 book ai didi

spring - 从 Spring 和 Tomcat 中的索引页面重定向

转载 作者:行者123 更新时间:2023-11-28 21:48:50 24 4
gpt4 key购买 nike

我有一个 Spring 应用程序,它在 Tomcat 上运行,地址为:http://example.com/foo/

DispatcherServlet映射到app/*,例如index页面为:

http://example.com/foo/app/index.html

这是因为我有其他 servlet(用于 HttpRequestHandlers),例如映射到服务/*。这种方案使用起来很方便,因为这样 app/和 service/可以有不同的安全设置。

我要的是http://example.com/foo重定向到 http://example.com/foo/app/index.html .

我如何实现这一目标?

最佳答案

在您的 web.xml 中,您可以定义一个欢迎文件,在导航到应用程序的根目录时可以看到:

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

然后你可以制作一个小的 index.jsp 重定向到你想要的地方:

<% response.sendRedirect("app/index.html"); %>

关于spring - 从 Spring 和 Tomcat 中的索引页面重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5727642/

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