servlet跳转jsp的第三种方式

除重定向和转发方式跳转jsp页面还可通过respond.getWriter().print()写入一个js标签设置href=“”进而跳转

如:

response.getWriter().print("<script type=\"text/javascript\">parent.location.href=\"/login.jsp\"</script>");

此时通过设置parent.location.href的可以使子模块跳转页面时,不会只在本模块下跳转,而转到父模块下跳转

即不会出现下面这样跳转:

猜你喜欢

转载自www.cnblogs.com/shouyaya/p/12748866.html