- 使用forward方式跳转
firstpage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
request.setAttribute("id",departId);
pageContext.forward("secondpage.jsp");
%>
secondpage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String departId = (String) request.getAttribute("id");
%>
- 使用redirect方式跳转
firstpage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% response.sendRedirect("secondpage.jsp?id=1"); %>
secondpage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String departId = (String) request.getParameter("id");
%>
- 使用include动态插入代码
firstpage.jsp
<jsp:include page="secondpage.jsp">
<jsp:param name="id" value='1'/>
</jsp:include>
secondpage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String departId = (String) request.getParameter("id");
%>