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();
 

導入されたバージョン:
1.0.0
作成者:
baba

コンストラクタの概要
Redirect(Class<? extends Action> actionClass)
          指定されたアクションクラスのindexメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<? extends Action> actionClass, String methodName)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<? extends Action> actionClass, String methodName, Map<String,String[]> parameters)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<? extends Action> actionClass, String methodName, Map<String,String[]> parameters, String protocol)
          指定されたアクションメソッドへリダイレクトするインスタンスを生成します。
Redirect(Class<? extends Action> 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<? extends Action> actionClass, HttpServletRequest request)
          リダイレクトする URL を計算します。
 Redirect characterEncoding(String characterEncoding)
          URI のエンコーディングを指定します。
protected  String encodeURL(String url, HttpServletResponse response)
          URL をエンコードします。
 void execute(Action action, Class<? extends Action> actionClass, Method method, 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 - リダイレクト先のプロトコル
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
path - リダイレクト先のパス
protocol - リダイレクト先のプロトコル
port - リダイレクト先のポート
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
actionClass - アクションクラス
例外:
ActionRuntimeException - リダイレクト先パスの構築に失敗した場合
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
例外:
ActionRuntimeException - リダイレクト先パスの構築に失敗した場合
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ
例外:
ActionRuntimeException - リダイレクト先パスの構築に失敗した場合
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ
protocol - リダイレクト先のプロトコル
例外:
ActionRuntimeException - リダイレクト先パスの構築に失敗した場合
導入されたバージョン:
1.1.0

Redirect

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

パラメータ:
actionClass - アクションクラス
methodName - メソッド名
parameters - パラメータ
protocol - リダイレクト先のプロトコル
port - リダイレクト先のポート
例外:
ActionRuntimeException - リダイレクト先パスの構築に失敗した場合
導入されたバージョン:
1.1.0
メソッドの詳細

getPath

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

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

execute

public void execute(Action action,
                    Class<? extends Action> actionClass,
                    Method method,
                    HttpServletRequest request,
                    HttpServletResponse response)
             throws Exception
処理を実行します。

定義:
インタフェース ActionResult 内の execute
パラメータ:
action - アクション
actionClass - アクションクラス
method - アクションメソッド
request - リクエスト
response - レスポンス
例外:
Exception

calculateRedirectURL

protected String calculateRedirectURL(String path,
                                      Class<? extends Action> 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 を出力したくない場合に使用してください。

戻り値:
このオブジェクト
導入されたバージョン:
1.1.0

param

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

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

param

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

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

param

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

パラメータ:
paramName - パラメータ名
paramValues - パラメータの値
戻り値:
このオブジェクト
導入されたバージョン:
1.1.0

characterEncoding

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

パラメータ:
characterEncoding - URI のエンコーディング
戻り値:
このオブジェクト
導入されたバージョン:
1.1.1

getPath

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

パスを取得します。

戻り値:
パス


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