質問編集履歴

2

誤字の修正

2020/04/27 01:26

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -232,7 +232,7 @@
232
232
 
233
233
  > **根本原因**
234
234
 
235
- > javax.el.PropertyNotFoundException: プロパティ[productId]がタイプ[examples.entity.GoodsModel]で見つかりません
235
+ > javax.el.PropertyNotFoundException: プロパティ[productId]がタイプ[practice.entity.GoodsModel]で見つかりません
236
236
 
237
237
  > javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260)
238
238
 

1

コントローラー、モデルの記載内容を追加

2020/04/27 01:26

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -26,17 +26,59 @@
26
26
 
27
27
  ```java
28
28
 
29
+ package practice.component.controller;
30
+
31
+
32
+
33
+ import org.springframework.beans.factory.annotation.Autowired;
34
+
35
+ import org.springframework.stereotype.Controller;
36
+
37
+ import org.springframework.web.bind.annotation.PathVariable;
38
+
39
+ import org.springframework.web.bind.annotation.RequestMapping;
40
+
41
+ import org.springframework.web.bind.annotation.RequestMethod;
42
+
43
+ import org.springframework.web.servlet.ModelAndView;
44
+
45
+ import practice.component.repository.GoodsDao;
46
+
47
+ import practice.entity.GoodsModel;
48
+
49
+
50
+
51
+ @Controller
52
+
53
+ public class GoodsDetailController {
54
+
55
+ @Autowired
56
+
57
+ private GoodsDao goodsDao;
58
+
59
+
60
+
61
+ public GoodsDetailController() {
62
+
63
+ super();
64
+
65
+ }
66
+
67
+
68
+
29
- @RequestMapping(value="/goods/detail_{productId}.do",method = RequestMethod.GET, produces="text/plain;charset=UTF-8")
69
+ @RequestMapping(value="/goods/detail_{productId}.do",method = RequestMethod.GET, produces="text/plain;charset=UTF-8")
30
-
70
+
31
- public ModelAndView detailView(@PathVariable("productId") String productId) {
71
+ public ModelAndView detailView(@PathVariable("productId") String productId) {
32
-
72
+
33
- GoodsModel goodsModel = this.goodsDao.getGoods(productId);
73
+ GoodsModel goodsModel = this.goodsDao.getGoods(productId);
34
-
35
-
36
-
74
+
75
+
76
+
37
- ModelAndView modelAndView = new ModelAndView("goods/detail", "goods", goodsModel);
77
+ ModelAndView modelAndView = new ModelAndView("goods/detail", "goods", goodsModel);
38
-
78
+
39
- return modelAndView;
79
+ return modelAndView;
80
+
81
+ }
40
82
 
41
83
  }
42
84
 
@@ -44,6 +86,74 @@
44
86
 
45
87
  ```
46
88
 
89
+ モデル
90
+
91
+ ```Java
92
+
93
+ package practice.entity;
94
+
95
+ public class GoodsModel {
96
+
97
+ /** 商品ID */
98
+
99
+ private String productid;
100
+
101
+ /** 商品名 */
102
+
103
+ private String productname;
104
+
105
+ /** 値段 */
106
+
107
+ private String price;
108
+
109
+
110
+
111
+ public String getProductid() {
112
+
113
+ return productid;
114
+
115
+ }
116
+
117
+ public void setProductid(String productid) {
118
+
119
+ this.productid = productid;
120
+
121
+ }
122
+
123
+ public String getProductname() {
124
+
125
+ return productname;
126
+
127
+ }
128
+
129
+ public void setProductname(String productname) {
130
+
131
+ this.productname = productname;
132
+
133
+ }
134
+
135
+ public String getPrice() {
136
+
137
+ return price;
138
+
139
+ }
140
+
141
+ public void setPrice(String price) {
142
+
143
+ this.price = price;
144
+
145
+ }
146
+
147
+ }
148
+
149
+ ```
150
+
151
+
152
+
153
+
154
+
155
+
156
+
47
157
  画面
48
158
 
49
159
  ```JSP