2011-04-20 16 views
4

我有一個Spring應用程序,這是Tomcat上運行發言權:http://example.com/foo/重定向從索引頁在春季和Tomcat

DisplatcherServlet被映射到應用程序/ *,例如,索引頁:

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

這是因爲我有其他servlet(用於HttpRequestHandlers),例如映射到服務/ *。該方案使用起來很方便,因爲這種方式的app /和service /可以有不同的安全設置。

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

我該如何做到這一點?

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

然後,您可以做一個小的index.jsp重定向到你想去的地方:

回答

8

在web.xml中,您可以導航到應用程序的根目錄時定義歡迎文件,看到:

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