首页 > 其他 > 详细

关于Response.redirect()方法

时间:2014-10-19 19:46:18      阅读:186      评论:0      收藏:0      [点我收藏+]

1. sendRedirect 后面要加上return。
2. sendRedirect 执行过程是先转向还是先执行后续代码再转向?
答: 先执行代码再转向,在一个sendRedirect后面不能再有其他向页面中写入的操作。

3. 关于在redirect中相对地址的写法:

在servlet中配置的Servlet请求URL为:
/test/servlet/TestRediect
请求URL
test/servlet/TestRediect
转向URL
/rediectPage.jsp : http://localhost:8080/rediectPage.jsp
./rediectPage.jsp : http://localhost:8080/webtest2/test/servlet/rediectPage.jsp
../rediectPage.jsp : http://localhost:8080/webtest2/test/rediectPage.jsp
.../rediectPage.jsp : http://localhost:8080/webtest2/test/servlet/.../rediectPage.jsp
使用点转向页面注意:
一个点相当于请求URL中去掉最底一层的URL/
两个点相当于请求URL中去掉最底两层的url/

最好使用:
/webtest2/rediectPage.jsp : http://localhost:8080/webtest2/rediectPage.jsp

关于Response.redirect()方法

原文:http://www.cnblogs.com/caiyao/p/4035227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!