java中如何跳转页面跳转页面

使用 HttpServletResponse.sendRedirect() 方法跳转页面

通过调用 HttpServletResponse 对象的 sendRedirect(String location) 方法,可以让浏览器重定向到指定的 URL 地址。例如:response.sendRedirect("/targetPage.jsp"); 这会通知浏览器重新请求 targetPage.jsp 页面,这种方式适合在客户端进行跳转操作。