RequstDispatcher类问题?

wtjd 2004-08-26 05:08:17
RequstDispatcher具体有什么作用,获取它有哪些途径?常常用在哪些场合?
谢谢解答!
...全文
76 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
umbrella1984 2004-08-26
  • 打赏
  • 举报
回复
可以用this.getServletContext().getRequestDispatcher()或者
ServletContext ctx=getServletContext();
ctx.getRequestDispatcher();
方法得到ServletContext接口的

刚刚少写了一句

:P
umbrella1984 2004-08-26
  • 打赏
  • 举报
回复
作用就是在容器上下文中做转发,例如从这个页面跳转到别的SERVLET页面。就跟ASP中的response.redirect或PHP中的header("location:a.php");相似的功能,但比他们强大的多。
gln 2004-08-26
  • 打赏
  • 举报
回复
它可以进行重定向,包含等操作.就相当于jsp里的include和forward
umbrella1984 2004-08-26
  • 打赏
  • 举报
回复
HttpServletRequest接口有一个RequstDispatcher
ServletContext接口有一个RequstDispatcher
不同的是HttpServletRequest可以用绝对与相对路径来表示,
而ServletContext只可以用绝对路径表示。
可以用request.getRequestDispatcher()得到HttpServletRequest接口的
可以用this.getServletContext().getRequestDispatcher()或者
ServletContext ctx=getServletContext();
方法得到ServletContext接口的

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧