質問編集履歴

2

型の変更

2022/05/06 19:02

投稿

milkcoffee
milkcoffee

スコア14

test CHANGED
File without changes
test CHANGED
@@ -15,7 +15,7 @@
15
15
  @GetMapping("{id}/edit")
16
16
  public String edit(@PathVariable String id, Model model) {
17
17
  Item item = repository.findById(id); ①
18
- model.addAtribute("item", item); ②
18
+ model.addAttribute("item", item); ②
19
19
  return "root/edit";
20
20
  }
21
21
  ```
@@ -90,9 +90,9 @@
90
90
  * 問題の箇所
91
91
  */
92
92
  @GetMapping("{id}/edit")
93
- public String edit(@PathVariable String id, Model model) {
93
+ public String edit(@PathVariable Long id, Model model) {
94
- Item item = repository.findById(id);
94
+ Optional<InquiryForm> item = repository.findById(id);
95
- model.addAtribute("item", item);
95
+ model.addAttribute("item", item);
96
96
  return "root/edit";
97
97
  }
98
98
  ```
@@ -112,7 +112,7 @@
112
112
  @Repository
113
113
 
114
114
  public interface InquiryRepository extends JpaRepository<InquiryForm, String>{
115
- Optional<InquiryForm> findById(String id);
115
+ Optional<InquiryForm> findById(Long id);
116
116
  List<InquiryForm> findAll();
117
117
  }
118
118
  ```

1

Spring Bootのタグの追加

2022/05/05 22:24

投稿

milkcoffee
milkcoffee

スコア14

test CHANGED
File without changes
test CHANGED
File without changes