代码
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setContentType("text/html");
httpServletResponse.getWriter().print("<script>alert('提示信息'); window.location.href='跳转的url';</script>");
本文介绍如何通过Java代码设置HTTP响应头来实现页面跳转功能。具体操作包括设置字符编码为UTF-8,内容类型为text/html,并通过获取响应输出流打印一段JavaScript代码,该代码用于显示提示信息并跳转到指定URL。
代码
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setContentType("text/html");
httpServletResponse.getWriter().print("<script>alert('提示信息'); window.location.href='跳转的url';</script>");
201
1072
2639