teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

質問内容の改善

2020/06/04 22:07

投稿

sodium_chem
sodium_chem

スコア2

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- JAVA(SpringBoot(sts4.5.1)でショッピングカート風なシステムを作っています。
3
+ JAVA(SpringToolSuite4でショッピングカート風なシステムを作っています。
4
4
  履歴を表示したいのですが、<tbody>内の構文がうまくかけず、すべての履歴が表示されず、表示しても最新で購入したもののみの履歴しか表示されません。
5
5
  今回、実現したいことは、履歴をすべて表示させることです。
6
6
  お手隙の際にご教授いただければ幸いです。
@@ -179,6 +179,6 @@
179
179
  ```
180
180
  ### 補足情報
181
181
 
182
- SpringBoot(sts4.5.1)を使用
182
+ SpringToolSite4(sts4.5.1)を使用
183
183
  java側でのforEachがきちんと機能せず、webのコンソールで確認した結果
184
184
  tbody内は書かれてないことになってます。

1

質問内容の改善

2020/06/04 22:07

投稿

sodium_chem
sodium_chem

スコア2

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- JAVA(SpringBoot4.0)でショッピングカート風なシステムを作っています。
3
+ JAVA(SpringBoot(sts4.5.1)でショッピングカート風なシステムを作っています。
4
4
  履歴を表示したいのですが、<tbody>内の構文がうまくかけず、すべての履歴が表示されず、表示しても最新で購入したもののみの履歴しか表示されません。
5
5
  今回、実現したいことは、履歴をすべて表示させることです。
6
6
  お手隙の際にご教授いただければ幸いです。
@@ -21,8 +21,102 @@
21
21
  return gson.toJson(historyDtoList);
22
22
  }
23
23
  ```
24
+ HistoryDto.java
25
+ ```java
26
+ public class HistoryDto {
24
27
 
28
+ private long id;
29
+
30
+ private long userId;
31
+
32
+ private long goodsId;
33
+
34
+ private String goodsName;
35
+
36
+ private long itemCount;
37
+
38
+ private long total;
39
+
40
+ private String createdAt;
41
+
42
+ public HistoryDto() {}
43
+
44
+ public HistoryDto(Purchase entity) {
45
+ this.id = entity.getId();
46
+ this.userId = entity.getUserId();
47
+ this.goodsId = entity.getGoodsId();
48
+ this.goodsName = entity.getGoodsName();
49
+ this.itemCount = entity.getItemCount();
50
+ this.total = entity.getTotal();
51
+
52
+ Timestamp d =entity.getCreatedAt();
53
+ SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
54
+ this.createdAt = f.format(d);
55
+ }
56
+
57
+ public HistoryDto(long id, long userId, long goodsId, String goodsName,long itemCount,long total,String createdAt) {
58
+ this.id = id;
59
+ this.userId = userId;
60
+ this.goodsId = goodsId;
61
+ this.goodsName = goodsName;
62
+ this.itemCount = itemCount;
63
+ this.total = total;
64
+ this.createdAt = createdAt;
65
+ }
66
+
67
+ public long getId() {
68
+ return id;
69
+ }
70
+ public void setId(long id) {
71
+ this.id = id;
72
+ }
73
+
74
+ public long getUserId() {
75
+ return userId;
76
+ }
77
+ public void setUserId(long userId) {
78
+ this.userId = userId;
79
+ }
80
+
81
+ public long getGoodsId() {
82
+ return goodsId;
83
+ }
84
+ public void setGoodsId(long goodsId) {
85
+ this.goodsId = goodsId;
86
+ }
87
+
88
+ public String getGoodName() {
89
+ return goodsName;
90
+ }
91
+ public void setGoodsName(String goodsName) {
92
+ this.goodsName = goodsName;
93
+ }
94
+
95
+ public long getItemCount() {
96
+ return itemCount;
97
+ }
98
+ public void setItemCount(long itemCount) {
99
+ this.itemCount = itemCount;
100
+ }
101
+
102
+ public long getTotal() {
103
+ return total;
104
+ }
105
+ public void setTotal(long total) {
106
+ this.total = total;
107
+ }
108
+
109
+ public String getCreatedAt() {
110
+ return createdAt;
111
+ }
112
+ public void setCreatedAt(String createdAt) {
113
+ this.createdAt = createdAt;
114
+ }
115
+ }
116
+ ```
25
117
 
118
+
119
+
26
120
  ### 書いたコード②(問題となる部分)
27
121
  Index.html
28
122
  ```html
@@ -85,4 +179,6 @@
85
179
  ```
86
180
  ### 補足情報
87
181
 
88
- SpringBoot4.0を使用
182
+ SpringBoot(sts4.5.1)を使用
183
+ java側でのforEachがきちんと機能せず、webのコンソールで確認した結果
184
+ tbody内は書かれてないことになってます。