|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectorg.seasar.cubby.action.Redirect
public class Redirect
指定されたパスにリダイレクトする 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();
コンストラクタの概要 | |
---|---|
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 |
コンストラクタの詳細 |
---|
public Redirect(String path)
path
- リダイレクト先のパスpublic Redirect(String path, String protocol)
path
- リダイレクト先のパスprotocol
- リダイレクト先のプロトコルpublic Redirect(String path, String protocol, int port)
path
- リダイレクト先のパスprotocol
- リダイレクト先のプロトコルport
- リダイレクト先のポートpublic Redirect(Class<?> actionClass)
actionClass
- アクションクラスpublic Redirect(Class<?> actionClass, String methodName)
actionClass
- アクションクラスmethodName
- メソッド名public Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters)
actionClass
- アクションクラスmethodName
- メソッド名parameters
- パラメータpublic Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters, String protocol)
actionClass
- アクションクラスmethodName
- メソッド名parameters
- パラメータprotocol
- リダイレクト先のプロトコルpublic Redirect(Class<?> actionClass, String methodName, Map<String,String[]> parameters, String protocol, int port)
actionClass
- アクションクラスmethodName
- メソッド名parameters
- パラメータprotocol
- リダイレクト先のプロトコルport
- リダイレクト先のポートメソッドの詳細 |
---|
public String getPath(String characterEncoding)
characterEncoding
- URI のエンコーディング
public void execute(ActionContext actionContext, HttpServletRequest request, HttpServletResponse response) throws Exception
ActionResult
内の execute
actionContext
- アクションコンテキストrequest
- 要求response
- 応答
Exception
protected String calculateRedirectURL(String path, Class<?> actionClass, HttpServletRequest request)
path
- パスactionClass
- アクションクラスrequest
- 要求
protected String encodeURL(String url, HttpServletResponse response)
url
- URLresponse
- 応答
HttpServletResponse.encodeRedirectURL(String)
public Redirect noEncodeURL()
HttpServletResponse.encodeRedirectURL(String)
によってエンコードせずにリダイレクトします。
URL 埋め込みのセッション ID を出力したくない場合に使用してください。
public Redirect param(String paramName, Object paramValue)
paramName
- パラメータ名paramValue
- パラメータの値。Object#toString()
の結果が値として使用されます。
public Redirect param(String paramName, Object[] paramValues)
paramName
- パラメータ名paramValues
- パラメータの値の配列。配列の要素のObject#toString()
の結果がそれぞれの値として使用されます。
public Redirect param(String paramName, String[] paramValues)
paramName
- パラメータ名paramValues
- パラメータの値
public Redirect characterEncoding(String characterEncoding)
characterEncoding
- URI のエンコーディング
@Deprecated public String getPath()
getPath(String)
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |