版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
前言
提示:以下是本篇文章正文内容,下面案例可供参考
一、法一
通过response.sendRedirect()进行跳转

1.java代码

代码如下(示例):
package kedun.dhy; import javax.servlet.*; import javax.servlet.http.*; @SuppressWarnings("serial") public class HttpSessionDemoServlet extends HttpServlet{ publicvoiddoGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException{ req.getSession().setAttribute("name","测试"); req.setAttribute("info","SZKEDUN"); resp.sendRedirect("get_info.jsp");} publicvoiddoPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException{ this.doGet(req, resp);}}

2.jsp代码

代码如下(示例):