org.seasar.cubby.action
クラス Redirect

java.lang.Object
  上位を拡張 org.seasar.cubby.action.Redirect
すべての実装されたインタフェース:
ActionResult

public class Redirect
extends Object
implements ActionResult

指定されたパスにリダイレクトする ActionResult です。

アクションメソッドの戻り値としてこのインスタンスを指定することで、指定されたパスにリダイレクトします。

使用例1 : リダイレクト先を相対パスで指定

 return new Redirect("list");
 

使用例2 : リダイレクト先を絶対パスで指定

 return new Redirect("/todo/list");
 

使用例3 : リダイレクト先をクラスとメソッド名で指定

 return new Redirect(TodoListAction.class, "show");
 

使用例4 : リダイレクト先をクラスとメソッド名で指定(paramメソッドによるパラメータつき)

 return new Redirect(TodoListAction.class, "show").param("value1", "12345");
 

使用例5 : リダイレクト先をクラスとメソッド名で指定(Mapによるパラメータつき)

 Map<String, String[]> parameters = new HashMap();
 parameters.put("value1", new String[] { "12345" });
 return new Redirect(TodoListAction.class, "show", parameters);
 

通常は HttpServletResponse.encodeRedirectURL(String) によってエンコードされた URL にリダイレクトするため、URL にセッション ID が埋め込まれます。 URL にセッション ID を埋め込みたくない場合は、noEncodeURL() を使用してください。

 return new Redirect("/todo/list").noEnocdeURL();
 

作成者:
baba

コンストラクタの概要
Redirect(Class<?> actionClass)
          指定されたアクションクラスのindexメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<?> actionClass, String methodName)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters, String protocol)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters, String protocol, int port)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(String path)
          インスタンスを生成します。
Redirect(String path, String protocol)
          インスタンスを生成します。
Redirect(String path, String protocol, int port)
          インスタンスを生成します。
 
メソッドの概要
protected  String calculateRedirectURL(String path, Class<?> actionClass, HttpServletRequest request)
          リダイレクトする URL を計算します。
 Redirect characterEncoding(String characterEncoding)
          URI のエンコーディングを指定します。
protected  String encodeURL(String url, HttpServletResponse response)
          URL をエンコードします。
 void execute(ActionContext actionContext, HttpServletRequest request, HttpServletResponse response)
          処理を実行します。
 String getPath()
          推奨されていません。 use getPath(String)
 String getPath(String characterEncoding)
          パスを取得します。
 Redirect noEncodeURL()
          HttpServletResponse.encodeRedirectURL(String) によってエンコードせずにリダイレクトします。
 Redirect param(String paramName, Object paramValue)
          パラメータを追加します。
 Redirect param(String paramName, Object[] paramValues)
          パラメータを追加します。
 Redirect param(String paramName, String[] paramValues)
          パラメータを追加します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Redirect

public Redirect(String path)
インスタンスを生成します。

パラメータ:
path - リダイレクト先のパス

Redirect

public Redirect(String path,
                String protocol)
インスタンスを生成します。

パラメータ:
path - リダイレクト先のパス
protocol - リダイレクト先のプロトコル

Redirect

public Redirect(String path,
                String protocol,
                int port)
インスタンスを生成します。

パラメータ:
path - リダイレクト先のパス
protocol - リダイレクト先のプロトコル
port - リダイレクト先のポート

Redirect

public Redirect(Class<?> actionClass)
指定されたアクションクラスのindexメソッドへリダイレクトするインスタンスを生成します。

パラメータ:
actionClass - アクションクラス

Redirect

public Redirect(Class<?> actionClass,
                String methodName)
指定されたアクションメソッドへリダイレクトするインスタンスを生成します。

パラメータ:
actionClass - アクションクラス
methodName - メソッド名

Redirect

public Redirect(Class<?> actionClass,
                String methodName,
                Map<String,String[]> parameters)
指定されたアクションメソッドへリダイレクトするインスタンスを生成します。

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ

Redirect

public Redirect(Class<?> actionClass,
                String methodName,
                Map<String,String[]> parameters,
                String protocol)
指定されたアクションメソッドへリダイレクトするインスタンスを生成します。

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ
protocol - リダイレクト先のプロトコル

Redirect

public Redirect(Class<?> actionClass,
                String methodName,
                Map<String,String[]> parameters,
                String protocol,
                int port)
指定されたアクションメソッドへリダイレクトするインスタンスを生成します。

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ
protocol - リダイレクト先のプロトコル
port - リダイレクト先のポート
メソッドの詳細

getPath

public String getPath(String characterEncoding)
パスを取得します。

パラメータ:
characterEncoding - URI のエンコーディング
戻り値:
パス

execute

public void execute(ActionContext actionContext,
                    HttpServletRequest request,
                    HttpServletResponse response)
             throws Exception
処理を実行します。

定義:
インタフェース ActionResult 内の execute
パラメータ:
actionContext - アクションコンテキスト
request - 要求
response - 応答
例外:
Exception

calculateRedirectURL

protected String calculateRedirectURL(String path,
                                      Class<?> actionClass,
                                      HttpServletRequest request)
リダイレクトする URL を計算します。

パラメータ:
path - パス
actionClass - アクションクラス
request - 要求
戻り値:
URL

encodeURL

protected String encodeURL(String url,
                           HttpServletResponse response)
URL をエンコードします。

パラメータ:
url - URL
response - 応答
戻り値:
エンコードされた URL
関連項目:
HttpServletResponse.encodeRedirectURL(String)

noEncodeURL

public Redirect noEncodeURL()
HttpServletResponse.encodeRedirectURL(String) によってエンコードせずにリダイレクトします。

URL 埋め込みのセッション ID を出力したくない場合に使用してください。

戻り値:
このオブジェクト

param

public Redirect param(String paramName,
                      Object paramValue)
パラメータを追加します。

パラメータ:
paramName - パラメータ名
paramValue - パラメータの値。Object#toString()の結果が値として使用されます。
戻り値:
このオブジェクト

param

public Redirect param(String paramName,
                      Object[] paramValues)
パラメータを追加します。

パラメータ:
paramName - パラメータ名
paramValues - パラメータの値の配列。配列の要素のObject#toString()の結果がそれぞれの値として使用されます。
戻り値:
このオブジェクト

param

public Redirect param(String paramName,
                      String[] paramValues)
パラメータを追加します。

パラメータ:
paramName - パラメータ名
paramValues - パラメータの値
戻り値:
このオブジェクト

characterEncoding

public Redirect characterEncoding(String characterEncoding)
URI のエンコーディングを指定します。

パラメータ:
characterEncoding - URI のエンコーディング
戻り値:
このオブジェクト

getPath

@Deprecated
public String getPath()
推奨されていません。 use getPath(String)

パスを取得します。

戻り値:
パス


Copyright © 2006-2010 The Seasar Foundation. All Rights Reserved.