質問編集履歴

2

画像添付

2020/03/28 10:02

投稿

nagahi
nagahi

スコア8

test CHANGED
File without changes
test CHANGED
@@ -172,7 +172,9 @@
172
172
 
173
173
  ```
174
174
 
175
+ ```jsp
176
+
175
- ```QandAList.jsp(質問一覧画面)
177
+ <!-- QandAList.jsp(質問一覧画面) -->
176
178
 
177
179
  <%@ page language="java" contentType="text/html; charset=UTF-8"
178
180
 
@@ -344,7 +346,9 @@
344
346
 
345
347
  ```
346
348
 
349
+ ```jsp
350
+
347
- ```QandARegist.jsp(質問登録画面)
351
+ <!-- QandARegist.jsp(質問登録画面) -->
348
352
 
349
353
  <%@ page language="java" contentType="text/html; charset=UTF-8"
350
354
 

1

エラー画面の添付

2020/03/28 10:02

投稿

nagahi
nagahi

スコア8

test CHANGED
File without changes
test CHANGED
@@ -4,8 +4,16 @@
4
4
 
5
5
 
6
6
 
7
+ ※質問登録画面でデータを入力し、質問一覧画面に遷移する際に
8
+
9
+  エラー発生します
10
+
11
+ ![イメージ説明](4bebe895449d2b26c8329f0e577b22fc.png)
12
+
7
13
  不備、修正箇所等教えていただけたら幸いです。
8
14
 
15
+
16
+
9
17
  ```java
10
18
 
11
19
  package servlet;
@@ -14,6 +22,8 @@
14
22
 
15
23
  import java.io.IOException;
16
24
 
25
+ import java.util.List;
26
+
17
27
 
18
28
 
19
29
  import javax.servlet.RequestDispatcher;
@@ -28,212 +38,318 @@
28
38
 
29
39
  import javax.servlet.http.HttpServletResponse;
30
40
 
31
-
41
+ import javax.servlet.http.HttpSession;
42
+
43
+
44
+
45
+ import model.GetQuestionListLogic;
46
+
47
+ import model.PostQuestionLogic;
48
+
49
+ import model.Question;
32
50
 
33
51
  /**
34
52
 
35
- * 最初の質問一覧へ遷移するservlet
53
+ * Servlet implementation class Doctest
36
54
 
37
55
  */
38
56
 
57
+
58
+
39
- @WebServlet("/QuestionListServlet")
59
+ @WebServlet("/RegistQuestionServlet")
40
-
60
+
41
- public class QuestionListServlet extends HttpServlet {
61
+ public class RegistQuestionServlet extends HttpServlet {
42
62
 
43
63
  private static final long serialVersionUID = 1L;
44
64
 
65
+
66
+
45
67
  /**
46
68
 
47
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
69
+ * @see HttpServlet#doget(HttpServletRequest request, HttpServletResponse response)
48
-
70
+
49
- */
71
+ */
50
-
72
+
51
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
73
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
74
+
75
+ throws ServletException, IOException {
76
+
77
+ //フォワード
52
78
 
53
79
  RequestDispatcher dispatcher =
54
80
 
55
- request.getRequestDispatcher("/WEB-INF/jsp/QuestionList.jsp");
81
+ request.getRequestDispatcher("/WEB-INF/jsp/QandARegist.jsp");
82
+
83
+ dispatcher.forward(request, response);
84
+
85
+ }
86
+
87
+
88
+
89
+ /**
90
+
91
+ * @see HttpServlet#dopost(HttpServletRequest request, HttpServletResponse response)
92
+
93
+ */
94
+
95
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
96
+
97
+ throws ServletException, IOException {
98
+
99
+ //文字コードエンコーディング
100
+
101
+ request.setCharacterEncoding("UTF-8");
102
+
103
+ //リクエストパラメータ取得
104
+
105
+ // int id = request.getParameter("id");
106
+
107
+ String handle_name = request.getParameter("handle_name");
108
+
109
+ String title = request.getParameter("title");
110
+
111
+ String contents = request.getParameter("contents");
112
+
113
+ int urgency = Integer.parseInt(request.getParameter("urgency"));
114
+
115
+ String edit_delete_key = request.getParameter("edit_delete_key");
116
+
117
+ String regist_timestamp = request.getParameter("regist_timestamp");
118
+
119
+ String update_timestamp = request.getParameter("update_timestamp");
120
+
121
+
122
+
123
+ // 質問リストに質問を追加
124
+
125
+ Question question = new Question(handle_name, title, contents, urgency, edit_delete_key, regist_timestamp, update_timestamp);
126
+
127
+ PostQuestionLogic postQuestionLogic = new PostQuestionLogic();
128
+
129
+ postQuestionLogic.execute(question);
130
+
131
+
132
+
133
+ //質問リスト取得
134
+
135
+ GetQuestionListLogic getQuestionListLogic = new GetQuestionListLogic();
136
+
137
+ List<Question> questionList = getQuestionListLogic.execute();
138
+
139
+
140
+
141
+ //セッションスコープにbeansのquestionを保存
142
+
143
+ HttpSession session = request.getSession();
144
+
145
+ session.setAttribute("handle_name", handle_name);
146
+
147
+ session.setAttribute("title", title);
148
+
149
+ session.setAttribute("contents", contents);
150
+
151
+ session.setAttribute("urgency", urgency);
152
+
153
+ session.setAttribute("edit_delete_key", edit_delete_key);
154
+
155
+ session.setAttribute("regist_timestamp", regist_timestamp);
156
+
157
+ session.setAttribute("update_timestamp", update_timestamp);
158
+
159
+
160
+
161
+ //フォワード
162
+
163
+ RequestDispatcher dispatcher =request.getRequestDispatcher("/WEB-INF/jsp/QandAList.jsp");
56
164
 
57
165
  dispatcher.forward(request, response);
58
166
 
167
+ }
168
+
59
169
  }
60
170
 
61
- }
171
+
62
172
 
63
173
  ```
64
174
 
65
- ```java
66
-
67
- package servlet;
68
-
69
-
70
-
71
- import java.io.IOException;
72
-
73
- import java.util.List;
74
-
75
-
76
-
77
- import javax.servlet.RequestDispatcher;
78
-
79
- import javax.servlet.ServletException;
80
-
81
- import javax.servlet.annotation.WebServlet;
82
-
83
- import javax.servlet.http.HttpServlet;
84
-
85
- import javax.servlet.http.HttpServletRequest;
86
-
87
- import javax.servlet.http.HttpServletResponse;
88
-
89
- import javax.servlet.http.HttpSession;
90
-
91
-
92
-
93
- import model.GetQuestionListLogic;
94
-
95
- import model.PostQuestionLogic;
96
-
97
- import model.Question;
98
-
99
- /**
100
-
101
- * Servlet implementation class Doctest
102
-
103
- */
104
-
105
-
106
-
107
- @WebServlet("/RegistQuestionServlet")
108
-
109
- public class RegistQuestionServlet extends HttpServlet {
110
-
111
- private static final long serialVersionUID = 1L;
112
-
113
-
114
-
115
- /**
116
-
117
- * @see HttpServlet#doget(HttpServletRequest request, HttpServletResponse response)
118
-
119
- */
120
-
121
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
122
-
123
- throws ServletException, IOException {
124
-
125
- //フォワード
126
-
127
- RequestDispatcher dispatcher =
128
-
129
- request.getRequestDispatcher("/WEB-INF/jsp/QandARegist.jsp");
130
-
131
- dispatcher.forward(request, response);
132
-
133
- }
134
-
135
-
136
-
137
- /**
138
-
139
- * @see HttpServlet#dopost(HttpServletRequest request, HttpServletResponse response)
140
-
141
- */
142
-
143
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
144
-
145
- throws ServletException, IOException {
146
-
147
- //文字コードエンコーディング
148
-
149
- request.setCharacterEncoding("UTF-8");
150
-
151
- //リクエストパラメータ取得
152
-
153
- // int id = request.getParameter("id");
154
-
155
- String handle_name = request.getParameter("handle_name");
156
-
157
- String title = request.getParameter("title");
158
-
159
- String contents = request.getParameter("contents");
160
-
161
- int urgency = Integer.parseInt(request.getParameter("urgency"));
162
-
163
- String edit_delete_key = request.getParameter("edit_delete_key");
164
-
165
- String regist_timestamp = request.getParameter("regist_timestamp");
166
-
167
- String update_timestamp = request.getParameter("update_timestamp");
168
-
169
-
170
-
171
- // 質問リストに質問を追加
172
-
173
- Question question = new Question(handle_name, title, contents, urgency, edit_delete_key, regist_timestamp, update_timestamp);
174
-
175
- PostQuestionLogic postQuestionLogic = new PostQuestionLogic();
176
-
177
- postQuestionLogic.execute(question);
178
-
179
-
180
-
181
- //質問リスト取得
182
-
183
- GetQuestionListLogic getQuestionListLogic = new GetQuestionListLogic();
184
-
185
- List<Question> questionList = getQuestionListLogic.execute();
186
-
187
-
188
-
189
- //セッションスコープにbeansのquestionを保存
190
-
191
- HttpSession session = request.getSession();
192
-
193
- session.setAttribute("handle_name", handle_name);
194
-
195
- session.setAttribute("title", title);
196
-
197
- session.setAttribute("contents", contents);
198
-
199
- session.setAttribute("urgency", urgency);
200
-
201
- session.setAttribute("edit_delete_key", edit_delete_key);
202
-
203
- session.setAttribute("regist_timestamp", regist_timestamp);
204
-
205
- session.setAttribute("update_timestamp", update_timestamp);
206
-
207
-
208
-
209
- //フォワード
210
-
211
- RequestDispatcher dispatcher =request.getRequestDispatcher("/WEB-INF/jsp/QandAList.jsp");
212
-
213
- dispatcher.forward(request, response);
214
-
215
- }
216
-
217
- }
218
-
219
-
175
+ ```QandAList.jsp(質問一覧画面)
176
+
177
+ <%@ page language="java" contentType="text/html; charset=UTF-8"
178
+
179
+ pageEncoding="UTF-8" %>
180
+
181
+ <%@ page import="model.Question"%>
182
+
183
+ <%
184
+
185
+ Question q = (Question)session.getAttribute("Question");
186
+
187
+ %>
188
+
189
+
190
+
191
+ <!DOCTYPE html>
192
+
193
+ <html lang="ja">
194
+
195
+ <head>
196
+
197
+ <meta charset="utf-8">
198
+
199
+ <meta name="viewport" content=“width=device-width,initial-scale=1.0”>
200
+
201
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
202
+
203
+ <title>課題1</title>
204
+
205
+ <link rel="stylesheet" href="css/QandAList.css">
206
+
207
+ </head>
208
+
209
+ <body>
210
+
211
+ <header>
212
+
213
+ <div class="container">
214
+
215
+ <p>質問一覧</p>
216
+
217
+ <a href="/QandASystem/RegistQuestionServlet">質問する</a>
218
+
219
+ </div>
220
+
221
+ </header>
222
+
223
+ <div class="main">
224
+
225
+ <div class="container">
226
+
227
+ <table border="1">
228
+
229
+ <thead>
230
+
231
+ <tr>
232
+
233
+ <th class="no" width="7%">No</th>
234
+
235
+ <th width="15%">緊急度</th>
236
+
237
+ <th width="40%">タイトル</th>
238
+
239
+ <th>登録者</th>
240
+
241
+ <th>登録日</th>
242
+
243
+ <th>更新日</th>
244
+
245
+ </tr>
246
+
247
+ </thead>
248
+
249
+ <tbody>
250
+
251
+ <tr>
252
+
253
+ <td>5</td>
254
+
255
+ <td><%=q.getUrgency()%></td>
256
+
257
+ <td><%=q.getTitle()%></td>
258
+
259
+ <td><%=q.getHandle_name() %></td>
260
+
261
+ <td><%=q.getRegist_timestamp() %></td>
262
+
263
+ <td><%=q.getUpdate_timestamp() %></td>
264
+
265
+ </tr>
266
+
267
+ <tr>
268
+
269
+ <td>4</td>
270
+
271
+ <td><%=q.getUrgency()%></td>
272
+
273
+ <td><%=q.getTitle()%></td>
274
+
275
+ <td><%=q.getHandle_name() %></td>
276
+
277
+ <td><%=q.getRegist_timestamp() %></td>
278
+
279
+ <td><%=q.getUpdate_timestamp() %></td>
280
+
281
+ </tr>
282
+
283
+ <tr>
284
+
285
+ <td>3</td>
286
+
287
+ <td><%=q.getUrgency()%></td>
288
+
289
+ <td><%=q.getTitle()%></td>
290
+
291
+ <td><%=q.getHandle_name() %></td>
292
+
293
+ <td><%=q.getRegist_timestamp() %></td>
294
+
295
+ <td><%=q.getUpdate_timestamp() %></td>
296
+
297
+ </tr>
298
+
299
+ <tr>
300
+
301
+ <td>2</td>
302
+
303
+ <td><%=q.getUrgency()%></td>
304
+
305
+ <td><%=q.getTitle()%></td>
306
+
307
+ <td><%=q.getHandle_name() %></td>
308
+
309
+ <td><%=q.getRegist_timestamp() %></td>
310
+
311
+ <td><%=q.getUpdate_timestamp() %></td>
312
+
313
+ </tr>
314
+
315
+ <tr>
316
+
317
+ <td>1</td>
318
+
319
+ <td><%=q.getUrgency()%></td>
320
+
321
+ <td><%=q.getTitle()%></td>
322
+
323
+ <td><%=q.getHandle_name() %></td>
324
+
325
+ <td><%=q.getRegist_timestamp() %></td>
326
+
327
+ <td><%=q.getUpdate_timestamp() %></td>
328
+
329
+ </tr>
330
+
331
+ </tbody>
332
+
333
+ </table>
334
+
335
+ </div>
336
+
337
+ </div>
338
+
339
+ <script src="js/main.js"></script>
340
+
341
+ </body>
342
+
343
+ </html>
220
344
 
221
345
  ```
222
346
 
223
- ```jsp
347
+ ```QandARegist.jsp(質問登録画面)
224
348
 
225
349
  <%@ page language="java" contentType="text/html; charset=UTF-8"
226
350
 
227
351
  pageEncoding="UTF-8" %>
228
352
 
229
- <%@ page import="model.Question"%>
230
-
231
- <%
232
-
233
- Question q = (Question)session.getAttribute("Question");
234
-
235
- %>
236
-
237
353
 
238
354
 
239
355
  <!DOCTYPE html>
@@ -244,270 +360,106 @@
244
360
 
245
361
  <meta charset="utf-8">
246
362
 
247
- <meta name="viewport" content=“width=device-width,initial-scale=1.0”>
248
-
249
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
250
-
251
- <title>課題1</title>
363
+ <title>質問登録画面</title>
252
-
364
+
253
- <link rel="stylesheet" href="css/QandAList.css">
365
+ <link rel="stylesheet" href="css/QandARegist.css">
254
366
 
255
367
  </head>
256
368
 
257
369
  <body>
258
370
 
259
- <header>
260
-
261
- <div class="container">
262
-
263
- <p>質問一覧</p>
264
-
265
- <a href="/QandASystem/RegistQuestionServlet">質問する</a>
266
-
267
- </div>
268
-
269
- </header>
270
-
271
- <div class="main">
272
-
273
- <div class="container">
274
-
275
- <table border="1">
276
-
277
- <thead>
278
-
279
- <tr>
280
-
281
- <th class="no" width="7%">No</th>
282
-
283
- <th width="15%">緊急度</th>
284
-
285
- <th width="40%">タイトル</th>
286
-
287
- <th>登録者</th>
288
-
289
- <th>登録日</th>
290
-
291
- <th>更新日</th>
292
-
293
- </tr>
294
-
295
- </thead>
296
-
297
- <tbody>
298
-
299
- <tr>
300
-
301
- <td>5</td>
302
-
303
- <td><%=q.getUrgency()%></td>
304
-
305
- <td><%=q.getTitle()%></td>
306
-
307
- <td><%=q.getHandle_name() %></td>
308
-
309
- <td><%=q.getRegist_timestamp() %></td>
310
-
311
- <td><%=q.getUpdate_timestamp() %></td>
312
-
313
- </tr>
314
-
315
- <tr>
316
-
317
- <td>4</td>
318
-
319
- <td><%=q.getUrgency()%></td>
320
-
321
- <td><%=q.getTitle()%></td>
322
-
323
- <td><%=q.getHandle_name() %></td>
324
-
325
- <td><%=q.getRegist_timestamp() %></td>
326
-
327
- <td><%=q.getUpdate_timestamp() %></td>
328
-
329
- </tr>
330
-
331
- <tr>
332
-
333
- <td>3</td>
334
-
335
- <td><%=q.getUrgency()%></td>
336
-
337
- <td><%=q.getTitle()%></td>
338
-
339
- <td><%=q.getHandle_name() %></td>
340
-
341
- <td><%=q.getRegist_timestamp() %></td>
342
-
343
- <td><%=q.getUpdate_timestamp() %></td>
344
-
345
- </tr>
346
-
347
- <tr>
348
-
349
- <td>2</td>
350
-
351
- <td><%=q.getUrgency()%></td>
352
-
353
- <td><%=q.getTitle()%></td>
354
-
355
- <td><%=q.getHandle_name() %></td>
356
-
357
- <td><%=q.getRegist_timestamp() %></td>
358
-
359
- <td><%=q.getUpdate_timestamp() %></td>
360
-
361
- </tr>
362
-
363
- <tr>
364
-
365
- <td>1</td>
366
-
367
- <td><%=q.getUrgency()%></td>
368
-
369
- <td><%=q.getTitle()%></td>
370
-
371
- <td><%=q.getHandle_name() %></td>
372
-
373
- <td><%=q.getRegist_timestamp() %></td>
374
-
375
- <td><%=q.getUpdate_timestamp() %></td>
376
-
377
- </tr>
378
-
379
- </tbody>
380
-
381
- </table>
382
-
383
- </div>
384
-
385
- </div>
386
-
387
- <script src="js/main.js"></script>
371
+ <header>
372
+
373
+ <div class="container">
374
+
375
+ <div class="header-flex">
376
+
377
+ <div class="header-left">
378
+
379
+ <h3>質問登録</h3>
380
+
381
+ </div>
382
+
383
+ <div class="header-right">
384
+
385
+ <a href="/QandASystem/QuestionListServlet class="btn">戻る</a>
386
+
387
+ </div>
388
+
389
+ </div>
390
+
391
+ </div>
392
+
393
+ </header>
394
+
395
+ <section class="question-form">
396
+
397
+ <div class="container">
398
+
399
+ <form action="/QandASystem/RegistQuestionServlet" method="post">
400
+
401
+ <table border="1">
402
+
403
+ <tr>
404
+
405
+ <th>名前(ハンドルネーム)</th>
406
+
407
+ <td><input type="text" class="inp"></td>
408
+
409
+ </tr>
410
+
411
+ <tr>
412
+
413
+ <th>タイトル</th>
414
+
415
+ <td><input type="text" class="inp"></td>
416
+
417
+ </tr>
418
+
419
+ <tr>
420
+
421
+ <th class="contents">内容</th>
422
+
423
+ <td><textarea rows="16"></textarea></td>
424
+
425
+ </tr>
426
+
427
+ <tr class="urgency">
428
+
429
+ <th>緊急度</th>
430
+
431
+ <td>
432
+
433
+ <label><input type="radio" name="urgency" value="1">急いでいます</label>
434
+
435
+ <label><input type="radio" name="urgency" value="2">困ってます</label>
436
+
437
+ <label><input type="radio" name="urgency" value="3">いつでも</label>
438
+
439
+ </td>
440
+
441
+ </tr>
442
+
443
+ <tr>
444
+
445
+ <th>編集・削除キー</th>
446
+
447
+ <td><input type="text" class="inp"></td>
448
+
449
+ </tr>
450
+
451
+ </table>
452
+
453
+ <input type="submit" value="登録">
454
+
455
+ </form>
456
+
457
+ </div>
458
+
459
+ </section>
388
460
 
389
461
  </body>
390
462
 
391
463
  </html>
392
464
 
393
465
  ```
394
-
395
- ```jsp
396
-
397
- <%@ page language="java" contentType="text/html; charset=UTF-8"
398
-
399
- pageEncoding="UTF-8" %>
400
-
401
-
402
-
403
- <!DOCTYPE html>
404
-
405
- <html lang="ja">
406
-
407
- <head>
408
-
409
- <meta charset="utf-8">
410
-
411
- <title>質問登録画面</title>
412
-
413
- <link rel="stylesheet" href="css/QandARegist.css">
414
-
415
- </head>
416
-
417
- <body>
418
-
419
- <header>
420
-
421
- <div class="container">
422
-
423
- <div class="header-flex">
424
-
425
- <div class="header-left">
426
-
427
- <h3>質問登録</h3>
428
-
429
- </div>
430
-
431
- <div class="header-right">
432
-
433
- <a href="/QandASystem/QuestionListServlet class="btn">戻る</a>
434
-
435
- </div>
436
-
437
- </div>
438
-
439
- </div>
440
-
441
- </header>
442
-
443
- <section class="question-form">
444
-
445
- <div class="container">
446
-
447
- <form action="/QandASystem/RegistQuestionServlet" method="post">
448
-
449
- <table border="1">
450
-
451
- <tr>
452
-
453
- <th>名前(ハンドルネーム)</th>
454
-
455
- <td><input type="text" class="inp"></td>
456
-
457
- </tr>
458
-
459
- <tr>
460
-
461
- <th>タイトル</th>
462
-
463
- <td><input type="text" class="inp"></td>
464
-
465
- </tr>
466
-
467
- <tr>
468
-
469
- <th class="contents">内容</th>
470
-
471
- <td><textarea rows="16"></textarea></td>
472
-
473
- </tr>
474
-
475
- <tr class="urgency">
476
-
477
- <th>緊急度</th>
478
-
479
- <td>
480
-
481
- <label><input type="radio" name="urgency" value="1">急いでいます</label>
482
-
483
- <label><input type="radio" name="urgency" value="2">困ってます</label>
484
-
485
- <label><input type="radio" name="urgency" value="3">いつでも</label>
486
-
487
- </td>
488
-
489
- </tr>
490
-
491
- <tr>
492
-
493
- <th>編集・削除キー</th>
494
-
495
- <td><input type="text" class="inp"></td>
496
-
497
- </tr>
498
-
499
- </table>
500
-
501
- <input type="submit" value="登録">
502
-
503
- </form>
504
-
505
- </div>
506
-
507
- </section>
508
-
509
- </body>
510
-
511
- </html>
512
-
513
- ```