質問編集履歴
1
Controllerのコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -116,6 +116,80 @@
|
|
116
116
|
|
117
117
|
}
|
118
118
|
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
```ここに言語名を入力
|
128
|
+
|
129
|
+
@Controller
|
130
|
+
|
131
|
+
public class InsertController {
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
@PersistenceContext
|
136
|
+
|
137
|
+
private EntityManager entityManager;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
@Autowired
|
142
|
+
|
143
|
+
private MemberRepository member_info;
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
@Autowired
|
148
|
+
|
149
|
+
private MemberDAO memberDao;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
@PostConstruct
|
154
|
+
|
155
|
+
public void init() {
|
156
|
+
|
157
|
+
memberDao = new MemberDAO(entityManager);
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
@RequestMapping(value = "/memberInsert", method = RequestMethod.POST)
|
164
|
+
|
165
|
+
//POSTデータをAccount,Memberインスタンスとして受け取る
|
166
|
+
|
167
|
+
public ModelAndView insertPost(@ModelAttribute Account account, @ModelAttribute Member member, ModelAndView mav) {
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
Integer accountId = memberDao.queryAccountId();
|
172
|
+
|
173
|
+
member.setAccountId(accountId);
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
//リダイレクト先を指定
|
178
|
+
|
179
|
+
mav = new ModelAndView("redirect:/home");
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
//ModelとView情報を返す
|
184
|
+
|
185
|
+
return mav;
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
119
193
|
```
|
120
194
|
|
121
195
|
|