客户端跳转:
1、链接跳转:< a href=””>< /a >
2、表单提交< form>< /form>
3、Response.sendRedirect(“3.jsp”);
4、< mata http-equiv=”refresh”, content=”3;2.jsp”/ >
5、response.setHeader(“refresh”,” 3;2.jsp”);
6、客户端跳转“/”代表站点根路径webapp,即http://localhost:8080
服务端跳转:
1、< jsp:forward page=””/>
2、pageContext.forward();
3、 request.getRequestDispatcher(“1.jsp”).forward(request,response);
4、服务器端跳转“/”代表web应用根路径,即:http://localhost:8080/Demo/
注意:使用时如果要使用相对路径时,只有在客户端跳转时加上${pageContext.request.contextPath },该值为web应用的名称。
另外
http://localhost:8080/Demo09_Filter/demo6/articles.jsp
request.getContextPath():表示web应用的名称,如/Demo09_Filter
request.getServletPath():表示的是url地址栏中web应用名称之后的地址/demo6/articles.jsp
本文详细介绍了客户端和服务端的网页跳转方法,包括链接跳转、表单提交、使用JSP和Servlet实现的重定向及转发等。同时解释了在不同情况下如何正确设置路径。
7909

被折叠的 条评论
为什么被折叠?



