Java 自动从一个 JSP 页面重定向到另一个

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18576159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 09:09:37  来源:igfitidea点击:

Automatically redirect from one JSP page to Another

javajsp

提问by IceNine

Is it possible to redirect a user automatically to a second jsp page as soon as the home page loads?

是否可以在主页加载后立即将用户自动重定向到第二个 jsp 页面?

采纳答案by Peter Trypsteen

There is an example of such a thing: JSP - Page Redirecting

有这样一个例子: JSP - Page Redirecting

Simplest is using sendRedirect:

最简单的是使用sendRedirect

public void response.sendRedirect(String location)
throws IOException 

回答by JohnMark13

With core JSTL libraries loaded <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>you can use:

加载核心 JSTL 库后,<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>您可以使用:

<c:redirect url="/home.html"/>