2013-01-05 68 views
2

嗨,我有一個上下文,我有這個上下文的映射問題。當我把這個到我的web.xml在web.xml中映射根[weblogic]

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

我只能這樣訪問。

http://domain.com/sub-context/

,但我想這樣

http://domain.com/sub-context

訪問我該怎麼辦?

編輯:我看到,當我在瀏覽器中找到http://domain.com/sub-context時,它將我重定向到http://domain.com/sub-context/,雖然我沒有做任何特別的事情。誰在做這件事。 Weblogic的?

回答

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); 
    } 

從這裏改編:redirect through web.xml in google-app-engine

+0

我想我誤會了。我有一個子上下文(有它自己的戰爭和一個web.xml中)。 – jit