【问题标题】:obtaining a requestDispatcher获取 requestDispatcher
【发布时间】:2008-10-01 14:21:50
【问题描述】:

使用 servletContext 而不是请求来获取 requestDispatcher 有什么好处?

servletContext.getRequestDispatcher(dispatchPath)

并使用

argRequest.getRequestDispatcher(dispatchPath)

【问题讨论】:

    标签: java servlets


    【解决方案1】:

    在 javadocs 中有黑白的

    http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)

    此方法与 ServletContext.getRequestDispatcher(java.lang.String) 是这种方法可以采取 相对路径。

    【讨论】:

      【解决方案2】:

      当你从ServletContext调用getRequestDispatcher时,需要提供绝对路径,但是对于ServletRequest对象,你需要提供相对路径。

      【讨论】:

        猜你喜欢
        • 2014-07-06
        • 2013-04-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-30
        • 2017-11-18
        • 2012-05-29
        • 1970-01-01
        相关资源
        最近更新 更多