質問編集履歴

2

誤字の修正

2021/02/06 04:14

投稿

ai_atoz
ai_atoz

スコア2

test CHANGED
File without changes
test CHANGED
@@ -20,11 +20,11 @@
20
20
 
21
21
  〜省略〜
22
22
 
23
- private static final String SELECT_SQL2 = "SELECT product_ID,product_genre_code,product_name,product_maker,product_price,product_stock,product_sales,product_remarks FROM t_product WHERE product_ID = ?;";
23
+ private static final String SELECT_SQL2 = "SELECT ID,name,remarks FROM aaa WHERE ID = ?;";
24
24
 
25
25
  //データベースから指定された1件のアカウント情報の検索を行うメソッド
26
26
 
27
- public DTO findID(int product_ID) {
27
+ public DTO findID(int ID) {
28
28
 
29
29
  DTO dto = new DTO();
30
30
 
@@ -42,27 +42,17 @@
42
42
 
43
43
  PreparedStatement smtement = conn.prepareStatement(SELECT_SQL2);
44
44
 
45
- smtement.setInt(1, product_ID);
45
+ smtement.setInt(1, ID);
46
46
 
47
47
  ResultSet result = smtement.executeQuery();
48
48
 
49
49
  while (result.next()) {
50
50
 
51
- dto.setProduct_ID(result.getInt("product_ID"));
51
+ dto.setProduct_ID(result.getInt("ID"));
52
-
53
- dto.setProduct_genre_code(result.getString("product_genre_code"));
52
+
54
-
55
- dto.setProduct_name(result.getString("product_name"));
53
+ dto.setProduct_name(result.getString("name"));
56
-
57
- dto.setProduct_maker(result.getString("product_maker"));
54
+
58
-
59
- dto.setProduct_price(result.getInt("product_price"));
60
-
61
- dto.setProduct_stock(result.getInt("product_stock"));
62
-
63
- dto.setProduct_sales(result.getInt("product_sales"));
64
-
65
- dto.setProduct_remarks(result.getString("product_remarks"));
55
+ dto.setProduct_remarks(result.getString("remarks"));
66
56
 
67
57
  }
68
58
 
@@ -102,161 +92,61 @@
102
92
 
103
93
 
104
94
 
105
- private int product_ID;
106
-
107
-
108
-
109
- private String product_genre_code;
110
-
111
-
112
-
113
- private String product_name;
114
-
115
-
116
-
117
- private String product_maker;
118
-
119
-
120
-
121
- private int product_price;
122
-
123
-
124
-
125
- private int product_stock;
126
-
127
-
128
-
129
- private int product_sales;
130
-
131
-
132
-
133
- private String product_remarks;
134
-
135
-
136
-
137
- public int getProduct_ID() {
138
-
139
- return product_ID;
140
-
141
- }
142
-
143
-
144
-
145
- public void setProduct_ID(int product_ID) {
146
-
147
- this.product_ID = product_ID;
148
-
149
- }
150
-
151
-
152
-
153
- public String getProduct_genre_code() {
154
-
155
- return product_genre_code;
156
-
157
- }
158
-
159
-
160
-
161
- public void setProduct_genre_code(String product_genre_code) {
162
-
163
- this.product_genre_code = product_genre_code;
164
-
165
- }
166
-
167
-
168
-
169
- public String getProduct_name() {
170
-
171
- return product_name;
172
-
173
- }
174
-
175
-
176
-
177
- public void setProduct_name(String product_name) {
178
-
179
- this.product_name = product_name;
180
-
181
- }
182
-
183
-
184
-
185
- public String getProduct_maker() {
186
-
187
- return product_maker;
188
-
189
- }
190
-
191
-
192
-
193
- public void setProduct_maker(String product_maker) {
194
-
195
- this.product_maker = product_maker;
196
-
197
- }
198
-
199
-
200
-
201
- public int getProduct_price() {
202
-
203
- return product_price;
204
-
205
- }
206
-
207
-
208
-
209
- public void setProduct_price(int product_price) {
210
-
211
- this.product_price = product_price;
212
-
213
- }
214
-
215
-
216
-
217
- public int getProduct_stock() {
218
-
219
- return product_stock;
220
-
221
- }
222
-
223
-
224
-
225
- public void setProduct_stock(int product_stock) {
226
-
227
- this.product_stock = product_stock;
228
-
229
- }
230
-
231
-
232
-
233
- public int getProduct_sales() {
234
-
235
- return product_sales;
236
-
237
- }
238
-
239
-
240
-
241
- public void setProduct_sales(int product_sales) {
242
-
243
- this.product_sales = product_sales;
244
-
245
- }
246
-
247
-
248
-
249
- public void setProduct_remarks(String product_remarks) {
250
-
251
- this.product_remarks = product_remarks;
252
-
253
- }
254
-
255
-
256
-
257
- public String getProduct_remarks() {
258
-
259
- return product_remarks;
95
+ private int ID;
96
+
97
+
98
+
99
+ private String name;
100
+
101
+
102
+
103
+ private String remarks;
104
+
105
+
106
+
107
+ public int getID() {
108
+
109
+ return ID;
110
+
111
+ }
112
+
113
+
114
+
115
+ public void setID(int ID) {
116
+
117
+ this.ID = ID;
118
+
119
+ }
120
+
121
+
122
+
123
+ public String getName() {
124
+
125
+ return name;
126
+
127
+ }
128
+
129
+
130
+
131
+ public void setName(String name) {
132
+
133
+ this.name = name;
134
+
135
+ }
136
+
137
+
138
+
139
+ public String getRremarks() {
140
+
141
+ return remarks;
142
+
143
+ }
144
+
145
+
146
+
147
+ public void setRemarks(String remarks) {
148
+
149
+ this.remarks = remarks;
260
150
 
261
151
  }
262
152
 
@@ -274,9 +164,9 @@
274
164
 
275
165
  */
276
166
 
277
- @WebServlet("/UpdateInfo")
167
+ @WebServlet("/Update")
278
-
168
+
279
- public class UpdateInfo extends HttpServlet {
169
+ public class Update extends HttpServlet {
280
170
 
281
171
  private static final long serialVersionUID = 1L;
282
172
 
@@ -288,7 +178,7 @@
288
178
 
289
179
  */
290
180
 
291
- public UpdateInfo() {
181
+ public Update() {
292
182
 
293
183
  super();
294
184
 
@@ -322,25 +212,15 @@
322
212
 
323
213
  //1件検索メソッドを呼び出し
324
214
 
325
- DTO dto = dao.findID(product_ID);
215
+ DTO dto = dao.findID(ID);
326
216
 
327
217
  //検索結果を持ってUpDate.jspにフォワード
328
218
 
329
- request.setAttribute("product_ID", product_ID);
219
+ request.setAttribute("ID", ID);
330
-
331
- request.setAttribute("product_genre_code", dto.getProduct_genre_code());
220
+
332
-
333
- request.setAttribute("product_name", dto.getProduct_name());
221
+ request.setAttribute("name", dto.getName());
334
-
335
- request.setAttribute("product_maker", dto.getProduct_maker());
222
+
336
-
337
- request.setAttribute("product_price", dto.getProduct_price());
338
-
339
- request.setAttribute("product_stock", dto.getProduct_stock());
340
-
341
- request.setAttribute("product_sales", dto.getProduct_sales());
342
-
343
- request.setAttribute("product_remarks", dto.getProduct_remarks());
223
+ request.setAttribute("remarks", dto.getRemarks());
344
224
 
345
225
  RequestDispatcher dispatch = request.getRequestDispatcher("WEB-INF/jsp/jsp");
346
226
 
@@ -378,176 +258,6 @@
378
258
 
379
259
  ```
380
260
 
381
-
382
-
383
- ```jsp
384
-
385
- <%@ page language="java" contentType="text/html; charset=UTF-8"
386
-
387
- pageEncoding="UTF-8"%>
388
-
389
- <%@ page import="product3.productGenre"%>
390
-
391
- <%@ page import="product3.productMaker"%>
392
-
393
- <%@ page import="product2.DTO"%>
394
-
395
- <%@ page import="product2.DAO"%>
396
-
397
- <%@ page import="product4.productBean"%>
398
-
399
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
400
-
401
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
402
-
403
-
404
-
405
- <jsp:useBean id="findID" class="product2.DTO" scope="request"/>
406
-
407
- <jsp:useBean id="now" class="java.util.Date" scope="request"/>
408
-
409
- <!DOCTYPE html>
410
-
411
- <html xmlns:th="http://www.thymeleaf.org">
412
-
413
- <head>
414
-
415
- <meta charset="UTF-8">
416
-
417
- <link rel="stylesheet" type="text/css" href="css/ProductInfo.css">
418
-
419
- <title>更新画面</title>
420
-
421
- </head>
422
-
423
- <body>
424
-
425
- <form action="/./Update" method="post">
426
-
427
-
428
-
429
- <div class="aaa">
430
-
431
- <c:forEach var="findID" items="${Product_ID}" >
432
-
433
- <ul>
434
-
435
- <li><label>商品ID</label></li>
436
-
437
- <li><input value="${findID.getProduct_ID()}" type="text"
438
-
439
- name="productID"></li>
440
-
441
-
442
-
443
- <li><label>商品名</label></li>
444
-
445
- <li><input value="${findID.getProduct_name()}" type="text"
446
-
447
- name="productName"></li>
448
-
449
-
450
-
451
- <li><label>金額</label></li>
452
-
453
- <li><input value="${findID.getProduct_price()}" type="text"
454
-
455
- name="productPrice"></li>
456
-
457
-
458
-
459
- <li><label>販売個数</label></li>
460
-
461
- <li><input value="${findID.getProduct_sales()}" type="text"
462
-
463
- name="productSale"></li>
464
-
465
- </ul>
466
-
467
- </div>
468
-
469
-
470
-
471
- <div class="bbb">
472
-
473
- <ul>
474
-
475
- <li><label>ジャンル</label></li>
476
-
477
- <li><select name="productGenre">
478
-
479
- <c:forEach var="genre" items="${productGenre.values()}">
480
-
481
- <option value="${genre.genreCode}"
482
-
483
- <c:if test="${ProductGenre.productGenreCode == genre.genreCode}">selected</c:if>>
484
-
485
- ${genre.genreName}</option>
486
-
487
- </c:forEach>
488
-
489
- </select></li>
490
-
491
-
492
-
493
- <li><label>メーカー名</label></li>
494
-
495
- <li><select name="productMaker">
496
-
497
- <c:forEach var="maker" items="${productMaker.values()}">
498
-
499
- <option
500
-
501
- <c:if test="${ProductMaker.productMaker == maker.makerName}">selected</c:if>>
502
-
503
- ${maker.makerName}</option>
504
-
505
- </c:forEach>
506
-
507
- </select></li>
508
-
509
-
510
-
511
- <li><label>在庫数</label></li>
512
-
513
- <li><input value="${findID.getProduct_stock()}" type="text"
514
-
515
- name="productStock"></li>
516
-
517
- </ul>
518
-
519
- </div>
520
-
521
-
522
-
523
- <div class="bottom">
524
-
525
- <ul>
526
-
527
- <li><label>備考</label></li>
528
-
529
- <li><textarea name="findID.getProductRemarks()"></textarea></li>
530
-
531
- </ul>
532
-
533
- <input type="image" src="img/更新.png">
534
-
535
-
536
-
537
- </div>
538
-
539
- </c:forEach>
540
-
541
- </form>
542
-
543
-
544
-
545
- </body>
546
-
547
- </html>
548
-
549
- ```
550
-
551
261
  ### 試したこと
552
262
 
553
263
  登録した値をfindIDで出力しようとしましたが値が取れません。

1

書式の訂正

2021/02/06 04:14

投稿

ai_atoz
ai_atoz

スコア2

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  PreparedStatement smtement = conn.prepareStatement(SELECT_SQL2);
44
44
 
45
- smtement.setObject(1, product_ID);
45
+ smtement.setInt(1, product_ID);
46
46
 
47
47
  ResultSet result = smtement.executeQuery();
48
48
 
@@ -556,10 +556,4 @@
556
556
 
557
557
  ### 補足情報(FW/ツールのバージョンなど)
558
558
 
559
- 開発環境構築はEclipseサーバーのタイプは「Tomcat v8.5 サーバー」になります。
559
+ 開発環境構築は2018-09Eclipseで、サーバーのタイプは「Tomcat v8.5 サーバー」になります。
560
-
561
- jspにてEL式で出力しようとしたら画面が消えてしまいます。
562
-
563
- <%=request.getAttribute("") %>だと値は出力されませんがHTMLの画面は写ります。
564
-
565
- こちらもご教授いただければ幸いです。