Jsp-jstl-core-url-tag

提供:Dev Guides
移動先:案内検索

JSTL-コア<c:url>タグ

*<c:url>* タグは、URLを文字列にフォーマットし、変数に保存します。 このタグは、必要に応じてURLの書き換えを自動的に実行します。 *var* 属性は、フォーマットされたURLを含む変数を指定します。
*JSTL* urlタグは、* response.encodeURL()*メソッドの呼び出しを記述するための代替メソッドにすぎません。 urlタグが提供する唯一の本当の利点は、children *param* タグで指定されたパラメーターを含む適切なURLエンコードです。

属性

*<c:url>* タグには次の属性があります-
Attribute Description Required Default
Value Base URL Yes None
context /followed by the name of a local web application No Current application
var Name of the variable to expose the processed URL No Print to page
scope Scope of the variable to expose the processed URL No Page

<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>

<html>
   <head>
      <title><c:url> Tag Example</title>
   </head>

   <body>
      <a href = "<c:url value = "/jsp/index"/>">TEST</a>
   </body>
</html>

これは、次の結果を生成します-

TEST