HttpServletResponse hrs = (HttpServletResponse)response;
hrs.setContentType("text ml; charset=utf-8");
ServletOutputStream os = hrs.getOutputStream();
String contextPath = ((HttpServletRequest)request).getContextPath();
os.print("<script>alert('test);window.location.href='"+contextPath+"/mypage/user_info.jsp';</script>");
/*ActionForward forward=new ActionForward("/mypage/user_info.jsp");
forward.setRedirect(true);*/
return null;
本文介绍了一个使用Java Web进行页面跳转的例子。通过设置响应类型为文本HTML并指定字符集为UTF-8,利用ServletOutputStream直接输出JavaScript代码来实现页面提示与自动跳转的功能。这种方式适用于简单的页面重定向场景。
3884

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



