【问题标题】:Mapping root in web.xml [weblogic]在 web.xml [weblogic] 中映射根
【发布时间】:2013-01-05 16:35:01
【问题描述】:

您好,我有一个上下文,我在这个上下文中有一个映射问题。当我把它放到我的 web.xml 中时

<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/,尽管我没有为此做任何特别的事情。谁在做这件事。网络逻辑?

【问题讨论】:

    标签: java mapping weblogic web.xml


    【解决方案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

    【讨论】:

    • 我想我被误解了。我有一个子上下文(有自己的战争和一个 web.xml)。
    猜你喜欢
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 2013-12-06
    • 2013-09-24
    • 2015-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多