teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

2015/02/06 03:00

投稿

raou
raou

スコア463

answer CHANGED
@@ -1,33 +1,29 @@
1
- 質問内容のコードは、ワイルドカードマッピングというものです。
1
+ 質問内容のコードは、ワイルドカードマッピングというものです。
2
- {}で囲むことにより、合致するアクション名に置換されるプレースホルダになります。
2
+ {}で囲むことにより、合致するアクション名に置換されるプレースホルダになります。
3
-
3
+
4
- 例えばaction要素でpath属性に"/hoge*"と指定すると、"/hogeCreate" や "/hogeUpdate"など先頭が"/hoge"で始まる全ページに合致します。
4
+ 例えばaction要素でpath属性に"/hoge*"と指定すると、"/hogeCreate" や "/hogeUpdate"など先頭が"/hoge"で始まる全ページに合致します。
5
- さらに、合致した文字列をマッピング先Actionクラスやforward先のパス指定に含めることができます。
5
+ さらに、合致した文字列をマッピング先Actionクラスやforward先のパス指定に含めることができます。
6
-
6
+
7
- (例)
7
+ (例)
8
- ```lang-<ここに言語を入力>
9
- <struts-config>
8
+ <struts-config>
10
- <action-mappings>
9
+ <action-mappings>
11
- <action path="/hoge*" type="com.hoge.webapp.Hoge{1}Action" >
10
+ <action path="/hoge*" type="com.hoge.webapp.Hoge{1}Action" >
12
- <forward name="success" path="/WEB-INF/jsp/{1}.jsp" />
11
+ <forward name="success" path="/WEB-INF/jsp/{1}.jsp" />
13
- </action>
12
+ </action>
14
- </action-mappings>
13
+ </action-mappings>
15
- </struts-config>
14
+ </struts-config>
16
-
17
- ```
15
+
18
- 質問内容の例でいくと、もしshow1とshow2という二つのアクションが存在する場合、ワイルドカードのパターンと合致します。
16
+ 質問内容の例でいくと、もしshow1とshow2という二つのアクションが存在する場合、ワイルドカードのパターンと合致します。
19
- よって、以下の定義がされているのと同じことになります。
17
+ よって、以下の定義がされているのと同じことになります。
20
-
21
- ```lang-<ここに言語を入力>
18
+
22
- <action name="show1" class="actions.sendRedirect.show1">
19
+ <action name="show1" class="actions.sendRedirect.show1">
23
- <result>/views/sendRedirect/show1.jsp</result>
20
+ <result>/views/sendRedirect/show1.jsp</result>
24
- <result name="redirect" type="redirect">${redirectUrl}</result>
21
+ <result name="redirect" type="redirect">${redirectUrl}</result>
25
- </action>
22
+ </action>
26
- <action name="show2" class="actions.sendRedirect.show2">
23
+ <action name="show2" class="actions.sendRedirect.show2">
27
- <result>/views/sendRedirect/show2.jsp</result>
24
+ <result>/views/sendRedirect/show2.jsp</result>
28
- <result name="redirect" type="redirect">${redirectUrl}</result>
25
+ <result name="redirect" type="redirect">${redirectUrl}</result>
29
- </action>
26
+ </action>
30
- ```
27
+
31
-
32
- ワイルドカードマッピングに関する詳細は下記リンク先(海外サイト)も参考にしてみて下さい。
28
+ ワイルドカードマッピングに関する詳細は下記リンク先(海外サイト)も参考にしてみて下さい。
33
- [http://struts.apache.org/2.x/docs/wildcard-mappings.html](http://struts.apache.org/2.x/docs/wildcard-mappings.html)
29
+ http://struts.apache.org/2.x/docs/wildcard-mappings.html