jsp:forward相当于requestDispatcher还是sendRedirect呢?

2021-07-13 10:30:34 浏览数 (1)

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也没变, 所以相当于requestDispatche

更多请看:https://blog.csdn.net/qq_44594371/article/details/103168056

jsp

0 人点赞