您好我有一个上下文,我有这个上下文的映射问题。当我把它放到我的web.xml
时<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
我只能这样访问。
但我想这样访问
我该怎么办?
编辑:我看到当我在浏览器中点击http://domain.com/sub-context时,它会将我重定向到http://domain.com/sub-context/,尽管我没有做任何特别的事情。谁在做这件事。的Weblogic?
答案 0 :(得分:1)
这是一种方式:
<filter-mapping>
<filter-name>RedirectFilter</filter-name>
<url-pattern>/sub-context</url-pattern>
</filter-mapping>
然后在RedirectFilter中:
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)resp;
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String redirectURL = "http://domain.com/sub-context/";
response.setHeader("Location", redirectURL);
}