I have a Spring application, which is running on Tomcat say at: htt开发者_高级运维p://example.com/foo/
DisplatcherServlet is mapped to app/*, for example, index page is:
http://example.com/foo/app/index.html
This is so because I have other servlets (for HttpRequestHandlers), e.g. mapped to service/*. This scheme is convenient to use because this way app/ and service/ can have different security settings.
What I want is http://example.com/foo to redirect to http://example.com/foo/app/index.html.
How do I achieve this?
In your web.xml, you can define a welcome file, seen when navigating to the root of the app:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
You can then make a tiny index.jsp that redirects to where you want:
<% response.sendRedirect("app/index.html"); %>
You can add the (tuckey) Url Rewrite Filter to your application.
It provides you the functionality to define URL rewrite rules in you Application (ingoing and outgoing).
So you can define a rewrite rule for \
that it rewrites to myApplication.startpage
- or something else.
@see: http://mattgivney.blogspot.com/2010/07/how-to-url-rewrite-in-spring-mvc.html - for a short example
精彩评论