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

从Spring和Tomcat中的索引页重定向,spring,tomcat,redirect,Spring,Tomcat,Redirect,我有一个Spring应用程序,它在Tomcat上运行,比如: DispatcherServlet映射到app/*,例如,索引页为: http://example.com/foo/app/index.html 这是因为我有其他servlet(用于HttpRequestHandler),例如映射到service/*。此方案使用方便,因为这样app/和service/可以具有不同的安全设置 我想要的是重定向到 如何实现这一点?在web.xml中,您可以定义一个欢迎文件,在导航到应用程序根目录时可以看

我有一个Spring应用程序,它在Tomcat上运行,比如:

DispatcherServlet映射到app/*,例如,索引页为:

http://example.com/foo/app/index.html
这是因为我有其他servlet(用于HttpRequestHandler),例如映射到service/*。此方案使用方便,因为这样app/和service/可以具有不同的安全设置

我想要的是重定向到


如何实现这一点?

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

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

index.jsp
然后,您可以制作一个小index.jsp,重定向到您想要的位置:

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

您可以将添加到应用程序中

它为您提供了在应用程序中定义URL重写规则(输入和输出)的功能

因此,您可以为
\
定义重写规则,并将其重写为
myApplication.startpage
-或其他内容

@请参阅:-以获取一个简短的示例