回答編集履歴

1

2015/02/18 03:39

投稿

idledesu
idledesu

スコア259

test CHANGED
@@ -8,78 +8,62 @@
8
8
 
9
9
  ◆例外ハンドラ(ExceptionHandler)を拡張
10
10
 
11
- ```lang-java
12
-
13
11
  public class CustomizeExceptionHandler extends ExceptionHandler {
14
12
 
15
13
 
16
14
 
17
- static Logger logger = Logger.getLogger(CustomizeExceptionHandler.class);
15
+ static Logger logger = Logger.getLogger(CustomizeExceptionHandler.class);
18
16
 
19
17
 
20
18
 
21
- public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, Act ionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException {
19
+ public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException {
22
20
 
23
- //ここに例外に関する処理を追加。
21
+ //ここに例外に関する処理を追加。
24
22
 
25
- //logger.error("例外発生: " + ex.getMessage());
23
+ //logger.error("例外発生: " + ex.getMessage());
26
24
 
27
- return super.execute(ex, ae, mapping, formInstance, request, response);
25
+ return super.execute(ex, ae, mapping, formInstance, request, response);
28
-
29
- }
30
26
 
31
27
  }
32
28
 
33
- ```
29
+ }
34
30
 
35
31
 
36
32
 
37
33
  ◆struts-config.xmlに拡張した例外ハンドラを追加
38
34
 
39
- ```lang-java
40
-
41
35
  <global-exceptions>
42
36
 
43
37
  <exception
44
38
 
45
- key="error.Exception"
39
+ key="error.Exception"
46
40
 
47
- type="java.lang.Throwable"
41
+ type="java.lang.Throwable"
48
42
 
49
- handler="examples.exceptions.CustomizeExceptionHandler" />
43
+ handler="examples.exceptions.CustomizeExceptionHandler" />
50
44
 
51
45
  </global-exceptions>
52
46
 
53
47
 
54
48
 
55
- ```
56
-
57
49
 
58
50
 
59
51
  ◆例外を握りつぶしていたら非チェック例外でラップする
60
52
 
61
- ```lang-java
62
-
63
53
  } catch (Exception e) {
64
54
 
65
- //何も処理なし
55
+ //何も処理なし
66
56
 
67
57
  }
68
58
 
69
59
 
70
60
 
71
- ```
72
-
73
61
  ↓変更
74
62
 
75
63
 
76
64
 
77
- ```lang-java
78
-
79
65
  } catch (Exception e) {
80
66
 
81
- throw new RuntimeException(e);
67
+ throw new RuntimeException(e);
82
68
 
83
69
  }
84
-
85
- ```