- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
为什么
getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the current servlet context
在哪里
getRequestDispatcher(String path) of the ServletContext can use the getContext(String uripath) method to obtain RequestDispatcher for resources in foreign contexts.
如何?
请帮忙
最佳答案
如果使用绝对路径,例如 ("/index.jsp"
),则没有区别。
如果使用相对路径,则必须使用HttpServletRequest.getRequestDispatcher()
。 ServletContext.getRequestDispatcher()
不允许。
例如,如果您在 http://example.com/myapp/subdir
上收到您的请求,
RequestDispatcher dispatcher =
request.getRequestDispatcher("index.jsp");
dispatcher.forward( request, response );
将请求转发到页面http://example.com/myapp/subdir/index.jsp
。
在任何情况下,您都不能将请求转发到上下文之外的资源。
关于java - ServletContext.getRequestDispatcher() 与 ServletRequest.getRequestDispatcher(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1411114/
为什么 getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the curr
如何使用位于另一个上下文中的 getRequestDispatcher() 重定向 Request 对象?或者我如何将存储在 Request 对象中的数据重定向到另一个 JSP? HTTP 协议(pr
嘿,我有一个代码可以拦截所有请求(GET 和 POST),并最终使用表单重定向到另一个页面。我希望当用户发布表单时,执行初始拦截的请求 我的实际代码: public void doFilter(Ser
有没有办法将 request.getRequestDispatcher 与 FQDN 一起使用?类似的东西 request.getRequestDispatcher("http://mysite.co
在我的 servlet 中,我将属性传递给我的 jsp 页面: request.setAttribute("value", value); request.getRequestDispatcher("
好吧,我尝试将信息从 servlet 发送到 jsp,所以我尝试使用 request.setAttribute() 和 respond.getRequestDispatcher("page.jsp")
ServletRequest接口(interface)的getRequestDispatcher()方法返回RequestDispatcher的对象。 我知道 getRequestDispatcher
@WebServlet("/") public class RootServlet extends HttpServlet { private static final long serial
我正在使用 JSP、JSTL 和 Java servlet 制作登录/注册页面,并且在 servlet 的 doPost() 方法中使用: request.setAttribute("message"
使用嵌入式tomcat,这段代码: System.out.println("getServletPath: " + request.getServletPath()); System.out.prin
在我的应用程序中,我使用 jsp:include 作为: 工作正常,但是当我在 servlet 中包含相同的 JSP 时: RequestDispatcher rd = getServletCont
我有 2 个 servlet,它们在 web.xml 内映射: /archiving/archive /archiving/reportgenerator 从 servlet arch
目前我正在准备 Java EE Web Component Developer 考试。 在考试学习指南和 Servlet API Java 文档中我都找到了那个方法 ServletRequest.ge
我有一个名为“插入”的 servlet,可将数据插入数据库。 在这个 servlet 的末尾,我有一个 getRequestDispatcher,它将用户发送到名为“outcome.jsp”的页面。我
在 servlet 中,我们可以使用 requestdispatcher,它将从一个 servlet 转发到同一项目中具有相同 session 的另一个 servlet。但是如果我使用不同的项目,ge
我有一个用例,通过设置一些属性将请求 URL 修剪到相同的上下文来分派(dispatch)请求。这是在同一个线程中还是在新线程中处理? 最佳答案 它将在同一个线程中处理。 Servlet specif
我有一个主 JSP 和进程 JSP。在进程 jsp 中,我正在提交响应并将响应转发到成功页面。 request.getRequestDispatcher("success.jsp").forward
我正在使用 tomcat 7.0.52 根据 API:HttpServletRequest.html#getServletPath() . ServletPath 应该是解码后的路径。然而,当我这样做
我有我的工作代码片段 protected void doPost(HttpServletRequest request, HttpServletResponse response)
req.getRequestDispatcher("jsp/viewArticles.jsp").forward(req, resp); 因此我们获得了请求的调度程序,并提供了路径。到目前为止还好。现
我是一名优秀的程序员,十分优秀!