回答編集履歴

1

2015/02/06 03:00

投稿

raou
raou

スコア463

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