Latest web development tutorials

<c:redirect> 標籤

JSP 標準標籤庫 JSP標準標籤庫

<c:redirect>標籤通過自動重寫URL來將瀏覽器重定向至一個新的URL,它提供內容相關的URL,並且支持c:param標籤。

語法格式

<c:redirect url="<string>" context="<string>"/>

屬性

c:redirect標籤有如下屬性:

屬性 描述 是否必要 默認值
url 目標URL
context 緊接著一個本地網絡應用程序的名稱 當前應用程序

實例演示

如果你需要向<c:import> 標籤傳遞參數, 請先用<c:url> 標籤來創建URL地址,如下所示:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:redirect 标签实例</title>
</head>
<body>
<c:redirect url="http://www.w3big.com"/>
</body>
</html>

瀏覽器打開以上頁面將跳轉至http://www.w3big.com。


JSP 標準標籤庫 JSP標準標籤庫