[英]Mapping root in web.xml [weblogic]
嗨,我有一个上下文,并且我对此上下文有一个映射问题。 当我把它放到我的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的?
这是一种方法:
<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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.