質問編集履歴
1
ああああああああああああああああああ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
ああああああああああああああああああ
|
body
CHANGED
@@ -1,100 +1,1 @@
|
|
1
|
-
### 前提・実現したいこと
|
2
|
-
ユーザー登録のリンク先をクリックして、
|
3
|
-
画面遷移をしたいです。
|
4
|
-
|
5
|
-
|
6
|
-
### 発生している問題・エラーメッセージ
|
7
|
-
|
8
|
-
Whitelabel Error Page
|
9
|
-
This application has no explicit mapping for /error, so you are seeing this as a fallback.
|
10
|
-
|
11
|
-
Mon Oct 04 20:48:02 JST 2021
|
12
|
-
There was an unexpected error (type=Not Found, status=404).
|
13
|
-
### 該当のソースコード
|
14
|
-
|
15
|
-
```html
|
16
|
-
<!DOCTYPE html>
|
17
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
18
|
-
xmlns:th="http://www.thymeleaf.org">
|
19
|
-
<head>
|
20
|
-
<meta charset="UTF-8">
|
21
|
-
<title>Insert title here</title>
|
22
|
-
</head>
|
23
|
-
<body>
|
24
|
-
<form action="/user/id-search" method="post" th:object="${requestdata}">
|
25
|
-
ID:<input type="text" name="id" size="40">
|
26
|
-
<input type="submit" value="search">
|
27
|
-
</form>
|
28
|
-
<div th:if=${userinfo}>
|
29
|
-
<table th:object=${userinfo}>
|
30
|
-
<tr>
|
31
|
-
<th>name</th>
|
32
|
-
<td th:text="*{id}"></td>
|
33
|
-
</tr>
|
34
|
-
<tr>
|
35
|
-
<th>address</th>
|
36
|
-
<td th:text="*{name}"></td>
|
37
|
-
</tr>
|
38
|
-
<tr>
|
39
|
-
<th>age</th>
|
40
|
-
<td th:text="*{age}"></td>
|
41
|
-
</tr>
|
42
|
-
</table>
|
43
|
-
</div>
|
44
|
-
<a th:href="@{user/create}">ユーザー登録</a>
|
45
|
-
</body>
|
46
|
-
</html>
|
47
|
-
```
|
48
|
-
```controller
|
49
|
-
|
1
|
+
ああああああああああああああああああああああああああああああああああああ
|
50
|
-
|
51
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
52
|
-
import org.springframework.stereotype.Controller;
|
53
|
-
import org.springframework.ui.Model;
|
54
|
-
import org.springframework.web.bind.annotation.GetMapping;
|
55
|
-
import org.springframework.web.bind.annotation.ModelAttribute;
|
56
|
-
import org.springframework.web.bind.annotation.PostMapping;
|
57
|
-
|
58
|
-
import com.example.demo.bean.Requestdata;
|
59
|
-
import com.example.demo.entity.User;
|
60
|
-
import com.example.demo.service.UserService;
|
61
|
-
|
62
|
-
@Controller
|
63
|
-
public class UserController {
|
64
|
-
|
65
|
-
@Autowired
|
66
|
-
UserService userService;
|
67
|
-
@GetMapping(value="/user/search")
|
68
|
-
public String displaysearch(Model model) {
|
69
|
-
return "user/search";
|
70
|
-
}
|
71
|
-
|
72
|
-
@PostMapping(value="user/id-search")
|
73
|
-
public String search(@ModelAttribute Requestdata requestdata,Model model) {
|
74
|
-
User user=userService.search(requestdata);
|
75
|
-
model.addAttribute("userinfo",user);
|
76
|
-
return "user/search";
|
77
|
-
}
|
78
|
-
|
79
|
-
@GetMapping(value="user/create")
|
80
|
-
public String insert(@ModelAttribute Requestdata requestdata,Model model) {
|
81
|
-
return "user/create";
|
82
|
-
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
@PostMapping(value="user/create")
|
87
|
-
String regist(@ModelAttribute Requestdata requestdata, Model model) {
|
88
|
-
User user=userService.insert(requestdata);
|
89
|
-
model.addAttribute("insertuser",user);
|
90
|
-
return "redirect:user/search";
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
```
|
95
|
-
|
96
|
-
### 試したこと
|
97
|
-
|
98
|
-
リンクを様々なものに変更してみましたが、いずれもエラーが起きてしまう状態でした。
|
99
|
-
jsp/servletのようにコントローラーを通じて、htmlを参照するというのはイメージがつくのですが、
|
100
|
-
やり方がいまいちわからないため質問させていただければと思います。
|