位置:首页 » 文章/教程分享 » JSTL c:redirect标签

<c:redirect>标签提供自动URL重写将浏览器重定向到另一个URL,它支持上下文相关的URL,并且它支持<c:param>标签。

属性:

<c:redirect>标签具有以下属性:

属性 描述 必须? 默认
url URL to redirect the user's browser to Yes None
context / followed by the name of a local web application No Current application

例子:

如果需要将参数传递到<c:import>标签,使用<c:url>标记首先创建的URL,如下所示:

<%@ 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.codeinn.net"/>
</body>
</html>

上面的例子将重定向请求到http://www.codeinn.net - 试一试。