質問編集履歴
2
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,15 +23,6 @@
|
|
23
23
|
}
|
24
24
|
</script>
|
25
25
|
<html>
|
26
|
-
<head>
|
27
|
-
<div
|
28
|
-
style="background-color: #00ccff; width: *px; padding: 6px; border: 1px solid #ccc">
|
29
|
-
研修システム</div>
|
30
|
-
<div
|
31
|
-
style="background-color: #ffccff; width: 240px; padding: 6px; border: 1px solid #ccc">
|
32
|
-
都道府県登録</div>
|
33
|
-
|
34
|
-
</head>
|
35
26
|
<body>
|
36
27
|
|
37
28
|
|
@@ -74,10 +65,6 @@
|
|
74
65
|
<input type="submit" name="register" value="削除"
|
75
66
|
style="position: absolute; left: 150px; bottom: 50px">
|
76
67
|
</c:if>
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
68
|
</table>
|
82
69
|
</div>
|
83
70
|
</div>
|
@@ -105,56 +92,37 @@
|
|
105
92
|
import training.dto.todouhuken.regist.TodouhukenRegistDto;
|
106
93
|
import training.logic.todouhuken.regist.TodouhukenRegistLogic;
|
107
94
|
|
108
|
-
/**
|
109
|
-
* 都道府県一覧画面ボタン押下時処理サーブレット
|
110
|
-
*/
|
111
95
|
@WebServlet("/TodouhukenSearch_Details")
|
112
96
|
public class TodouhukenSearch_DetailsServlet extends HttpServlet {
|
113
97
|
private static final long serialVersionUID = 1L;
|
114
98
|
|
115
|
-
/**
|
116
|
-
* 都道府県一覧画面ボタン押下時処理
|
117
|
-
*
|
118
|
-
* 押下されたボタンに応じてサーブレットパスを設定し、画面遷移する。
|
119
|
-
*
|
120
|
-
*/
|
121
99
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
122
100
|
throws ServletException, IOException {
|
123
101
|
|
124
|
-
// 文字エンコードの設定(リクエスト)
|
125
102
|
request.setCharacterEncoding("utf-8");
|
126
103
|
|
127
|
-
// リクエストパラメータから値取得
|
128
104
|
String kennBanngo = request.getParameter("kennBanngo");
|
129
105
|
|
130
|
-
// 都道府県一覧画面用DTOを生成
|
131
106
|
TodouhukenRegistDto dto = new TodouhukenRegistDto();
|
132
|
-
|
133
|
-
|
107
|
+
|
134
108
|
dto.setkennBanngo(kennBanngo);
|
135
109
|
|
136
|
-
// 一覧の情報取得
|
137
110
|
TodouhukenRegistLogic logic = new TodouhukenRegistLogic();
|
138
111
|
logic.getTodouhukenList(dto);
|
139
112
|
|
140
|
-
// 画面表示時に使用する値を設定
|
141
113
|
request.setAttribute("kennBanngo", dto.getSelectTodouhukenDetail().getKennBanngo());
|
142
114
|
request.setAttribute("kennmei", dto.getSelectTodouhukenDetail().getKennmei());
|
143
115
|
request.setAttribute("kenncyouSyozaichi", dto.getSelectTodouhukenDetail().getKenncyouSyozaichi());
|
144
116
|
request.setAttribute("chihou", dto.getSelectTodouhukenDetail().getChihou());
|
145
117
|
request.setAttribute("jinnkou", dto.getSelectTodouhukenDetail().getJinnkou());
|
146
118
|
|
147
|
-
// 取得した一覧を設定
|
148
|
-
|
119
|
+
request.setAttribute("selectTodouhukenDetail", dto.getSelectTodouhukenDetail());
|
149
120
|
|
150
|
-
// 文字エンコードの設定(レスポンス)
|
151
121
|
response.setContentType("text/html; utf-8");
|
152
122
|
|
153
|
-
// フォワード先をregist.jspに設定
|
154
123
|
String forwardPath = "/WEB-INF/view/todouhuken_regist.jsp";
|
155
124
|
RequestDispatcher dispatcher = request.getRequestDispatcher(forwardPath);
|
156
125
|
|
157
|
-
// フォワード実行
|
158
126
|
dispatcher.forward(request, response);
|
159
127
|
|
160
128
|
}
|
@@ -184,12 +152,6 @@
|
|
184
152
|
</script>
|
185
153
|
</head>
|
186
154
|
<body>
|
187
|
-
<div
|
188
|
-
style="background-color: #00ccff; width: *px; padding: 10px; border: 1px solid #ccc">
|
189
|
-
研修システム</div>
|
190
|
-
<div
|
191
|
-
style="background-color: #ffccff; width: 240px; padding: 10px; border: 1px solid #ccc">
|
192
|
-
都道府県一覧</div>
|
193
155
|
<form method="post" action="?">
|
194
156
|
<div class="content">
|
195
157
|
<div class="searchCond">
|
@@ -265,4 +227,108 @@
|
|
265
227
|
|
266
228
|
</body>
|
267
229
|
</html>
|
230
|
+
```
|
231
|
+
TodouhukenRegistLogic
|
232
|
+
```
|
233
|
+
package training.logic.todouhuken.regist;
|
234
|
+
|
235
|
+
|
236
|
+
import training.common.dao.table.TodouhukenDao;
|
237
|
+
import training.common.dto.table.TodouhukenDto;
|
238
|
+
import training.common.logic.BaseLogic;
|
239
|
+
import training.dto.todouhuken.regist.TodouhukenRegistDto;
|
240
|
+
|
241
|
+
public class TodouhukenRegistLogic extends BaseLogic {
|
242
|
+
|
243
|
+
public void getTodouhukenList(TodouhukenRegistDto dto) {
|
244
|
+
|
245
|
+
try {
|
246
|
+
|
247
|
+
getConnection();
|
248
|
+
|
249
|
+
TodouhukenDao todouhukenDao = new TodouhukenDao(con);
|
250
|
+
|
251
|
+
TodouhukenDto todouhuken = todouhukenDao.selectTodouhukenDetail(dto.getkennBanngo());
|
252
|
+
|
253
|
+
dto.setSelectTodouhukenDetail(todouhuken);
|
254
|
+
|
255
|
+
closeConnection();
|
256
|
+
|
257
|
+
} catch (Exception e) {
|
258
|
+
|
259
|
+
e.printStackTrace();
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
```
|
264
|
+
TodouhukenRegistDto
|
265
|
+
```
|
266
|
+
package training.dto.todouhuken.regist;
|
267
|
+
|
268
|
+
import java.io.Serializable;
|
269
|
+
|
270
|
+
import training.common.dto.table.TodouhukenDto;
|
271
|
+
|
272
|
+
public class TodouhukenRegistDto implements Serializable {
|
273
|
+
|
274
|
+
private static final long serialVersionUID = 1L;
|
275
|
+
|
276
|
+
private String kennmei = null;
|
277
|
+
|
278
|
+
public String getKennmei() {
|
279
|
+
return kennmei;
|
280
|
+
}
|
281
|
+
|
282
|
+
public void setKennmei(String kennmei) {
|
283
|
+
this.kennmei = kennmei;
|
284
|
+
}
|
285
|
+
|
286
|
+
private String chihou = null;
|
287
|
+
|
288
|
+
public String getChihou() {
|
289
|
+
return chihou;
|
290
|
+
}
|
291
|
+
|
292
|
+
public void setChihou(String chihou) {
|
293
|
+
this.chihou = chihou;
|
294
|
+
}
|
295
|
+
|
296
|
+
private String jinnkou = null;
|
297
|
+
|
298
|
+
public String getJinnkou() {
|
299
|
+
return jinnkou;
|
300
|
+
}
|
301
|
+
|
302
|
+
public void setJinnkou(String jinnkou) {
|
303
|
+
this.jinnkou = jinnkou;
|
304
|
+
}
|
305
|
+
|
306
|
+
private String kennBanngo = null;
|
307
|
+
|
308
|
+
public String getkennBanngo() {
|
309
|
+
return kennBanngo;
|
310
|
+
}
|
311
|
+
|
312
|
+
public void setkennBanngo(String kennBanngo) {
|
313
|
+
this.kennBanngo = kennBanngo;
|
314
|
+
}
|
315
|
+
|
316
|
+
private String kenncyouSyozaichi = null;
|
317
|
+
|
318
|
+
public String getkenncyouSyozaichi() {
|
319
|
+
return kenncyouSyozaichi;
|
320
|
+
}
|
321
|
+
|
322
|
+
public void setkenncyouSyozaichi(String kenncyouSyozaichi) {
|
323
|
+
this.kenncyouSyozaichi = kenncyouSyozaichi;
|
324
|
+
}
|
325
|
+
|
326
|
+
private TodouhukenDto selectTodouhukenDetail = null;
|
327
|
+
public TodouhukenDto getSelectTodouhukenDetail() {
|
328
|
+
return selectTodouhukenDetail;
|
329
|
+
}
|
330
|
+
public void setSelectTodouhukenDetail(TodouhukenDto selectTodouhukenDetail) {
|
331
|
+
this.selectTodouhukenDetail = selectTodouhukenDetail;
|
332
|
+
}
|
333
|
+
}
|
268
334
|
```
|
1
説明の追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
### 詳細ボタンを押した県の情報を表示したい
|
2
|
+
todouhuken_search.jspでテーブル検索をした後
|
3
|
+
todouhuken_search.jspの詳細ボタンを押下時に、
|
2
|
-
|
4
|
+
県番号をサーブレットからtodouhuken_regist.jspに値を渡し押した県の詳細を表示させたいです。
|
3
5
|
|
4
|
-
|
6
|
+
todouhuken_search.jsp:検索画面
|
7
|
+
todouhuken_regist.jsp:登録画面
|
8
|
+
TodouhukenSearch_DetailsServlet:サーブレット
|
5
9
|
### 発生している問題・エラーメッセージ
|
6
10
|
|
7
11
|
どこを押しても沖縄県になる
|
8
12
|
|
9
13
|
### 該当のソースコード
|
10
|
-
|
14
|
+
todouhuken_regist.jsp
|
11
15
|
```ここに言語名を入力
|
12
16
|
<%@ page language="java" contentType="text/html; charset=utf-8"
|
13
17
|
pageEncoding="utf-8"%>
|
@@ -85,6 +89,7 @@
|
|
85
89
|
</body>
|
86
90
|
</html>
|
87
91
|
```
|
92
|
+
TodouhukenSearch_DetailsServlet
|
88
93
|
```
|
89
94
|
package training.controller.todouhuken.regist;
|
90
95
|
|
@@ -156,6 +161,7 @@
|
|
156
161
|
|
157
162
|
}
|
158
163
|
```
|
164
|
+
todouhuken_search.jsp
|
159
165
|
```
|
160
166
|
<%@ page language="java" contentType="text/html; charset=utf-8"
|
161
167
|
pageEncoding="utf-8"%>
|