JSTL Core < c:redirect > 标签
<c:redirect>
标签通过提供自动 URL 重写,将浏览器重定向到另一个 URL,它支持上下文相关的 URL,支持 <c:param>
标签。
属性
<c:redirect>
标签具有如下所示属性:
属性 | 描述 | 是否必需 | 默认值 |
---|---|---|---|
url | 重定向到用户浏览器的 URL | 是 | 无 |
context | / 紧随其后的是一个本地 web 应用程序 | 无 | 当前应用程序 |
实例:
如果你需要传递参数到
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title><c:redirect> Tag Example</title> </head> <body> <c:redirect url="http://www.photofuntoos.com"/> </body> </html>
上述例子会重定向请求到 http://www.photofuntoos.com——你可以自己尝试一下。