jsp:forward相当于requestDispatcher还是sendRedirect呢?下面的实验给出答案。
例 4.3.2:
<%@ page contentType="text/html; charset=GBK"%>
<% request.setAttribute("name","马克-to-win"); %>
<jsp:forward page="jsp2.jsp"/>
jsp2.jsp:
<body>
name is <%=request.getAttribute("name")%>
</body>
浏览器里的输出结果是:
name is 马克-to-win
地址栏里的url也没变, 所以相当于requestDispatcher
更多请看:https://blog.youkuaiyun.com/qq_44594371/article/details/103168056
本文通过实验对比了jsp:forward与requestDispatcher及sendRedirect的区别,证实jsp:forward在页面跳转时保留请求属性,且URL不变,更接近requestDispatcher的功能。
213

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



