質問編集履歴
3
エラーの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,18 @@
|
|
16
16
|
|
17
17
|
```
|
18
18
|
|
19
|
+
追記したエラーになります。
|
20
|
+
|
21
|
+
2020-12-05 23:56:38.489 ERROR 19732 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/test1.html]")] with root cause
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'day1_st1' cannot be found on null
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
先ほど回答を頂いた方に言及して頂いたエラーになります。
|
30
|
+
|
19
31
|
java.lang.IllegalStateException: No primary or single public constructor found for interface org.springframework.security.core.Authentication - and no default constructor found either
|
20
32
|
|
21
33
|
```
|
2
追記の為
test
CHANGED
File without changes
|
test
CHANGED
@@ -158,6 +158,72 @@
|
|
158
158
|
|
159
159
|
```
|
160
160
|
|
161
|
+
Attendance.java
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
package com.example.demo.model;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
import javax.persistence.Entity;
|
170
|
+
|
171
|
+
import javax.persistence.GeneratedValue;
|
172
|
+
|
173
|
+
import javax.persistence.GenerationType;
|
174
|
+
|
175
|
+
import javax.persistence.Id;
|
176
|
+
|
177
|
+
import javax.validation.constraints.Size;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
import lombok.Getter;
|
182
|
+
|
183
|
+
import lombok.Setter;
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
@Getter
|
188
|
+
|
189
|
+
@Setter
|
190
|
+
|
191
|
+
@Entity
|
192
|
+
|
193
|
+
public class Attendance {
|
194
|
+
|
195
|
+
@Id
|
196
|
+
|
197
|
+
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
198
|
+
|
199
|
+
private Long id;
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
@Size(min = 2, max = 20)
|
204
|
+
|
205
|
+
private String username;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
private int month;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
private int day1_st1;
|
214
|
+
|
215
|
+
private int day1_st2;
|
216
|
+
|
217
|
+
private int day1_end1;
|
218
|
+
|
219
|
+
private int day1_end2;
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
```
|
226
|
+
|
161
227
|
|
162
228
|
|
163
229
|
### 試したこと
|
1
追記の為
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,175 @@
|
|
1
1
|
現在、勤怠管理ができるアプリを作ろうと思っています。その中で、
|
2
2
|
|
3
3
|
spring boot で entityとして作成したクラスに値を入力したいと思っていますが、エラーが出てています。
|
4
|
+
|
5
|
+
### 前提・実現したいこと
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### 発生している問題・エラーメッセージ
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
java.lang.IllegalStateException: No primary or single public constructor found for interface org.springframework.security.core.Authentication - and no default constructor found either
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
### 該当のソースコード
|
26
|
+
|
27
|
+
test1.html
|
28
|
+
|
29
|
+
```ここに言語名を入力
|
30
|
+
|
31
|
+
<!DOCTYPE html>
|
32
|
+
|
33
|
+
<html xmlns:th="http://www.thymeleaf.org">
|
34
|
+
|
35
|
+
<head>
|
36
|
+
|
37
|
+
<meta charset="UTF-8">
|
38
|
+
|
39
|
+
<title>Insert title here</title>
|
40
|
+
|
41
|
+
</head>
|
42
|
+
|
43
|
+
<body>
|
44
|
+
|
45
|
+
border="1" width="50%" align="center">
|
46
|
+
|
47
|
+
<form th:action="@{/attendance}" th:object="${Attendance}" method="post">
|
48
|
+
|
49
|
+
<tr><!-- ここから -->
|
50
|
+
|
51
|
+
<td th:text=${month}></td>
|
52
|
+
|
53
|
+
<th><input type="number" name="day1_st1" th:value="*{day1_st1}"max = 24 min = 0 >:<input type=number name="day1_st2" th:value="*{day1_st2}" max = 60 min = 0 ></th><!-- ここに出金時間を入れます -->
|
54
|
+
|
55
|
+
<th><input type="number" name="day1_end1" th:value="*{day1_end1}"max = 24 min = 0 >:<input type=number name="day1_end2" th:value="*{day1_end2}" max = 60 min = 0 ></th><!-- ここに退勤時間を入れます -->
|
56
|
+
|
57
|
+
<th></th><!-- ここに休憩時間を入れます -->
|
58
|
+
|
59
|
+
<th>勤務時間</th><!-- ここに勤務時間を入れます -->
|
60
|
+
|
61
|
+
</tr><!-- ここまで -->
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
</body>
|
72
|
+
|
73
|
+
</html>
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
SecurityController.java
|
82
|
+
|
83
|
+
```ここに言語名を入力
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
package com.example.demo.controller;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
import org.springframework.security.core.Authentication;
|
92
|
+
|
93
|
+
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
94
|
+
|
95
|
+
import org.springframework.stereotype.Controller;
|
96
|
+
|
97
|
+
import org.springframework.ui.Model;
|
98
|
+
|
99
|
+
import org.springframework.validation.BindingResult;
|
100
|
+
|
101
|
+
import org.springframework.validation.annotation.Validated;
|
102
|
+
|
103
|
+
import org.springframework.web.bind.annotation.GetMapping;
|
104
|
+
|
105
|
+
import org.springframework.web.bind.annotation.ModelAttribute;
|
106
|
+
|
107
|
+
import org.springframework.web.bind.annotation.PostMapping;
|
108
|
+
|
109
|
+
import org.springframework.web.servlet.ModelAndView;
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
import com.example.demo.model.Attendance;
|
114
|
+
|
115
|
+
import com.example.demo.model.SiteUser;
|
116
|
+
|
117
|
+
import com.example.demo.repository.AttendanceRepository;
|
118
|
+
|
119
|
+
import com.example.demo.repository.SiteUserRepository;
|
120
|
+
|
121
|
+
import com.example.demo.util.Role;
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
import lombok.RequiredArgsConstructor;
|
126
|
+
|
127
|
+
@RequiredArgsConstructor
|
128
|
+
|
129
|
+
@Controller
|
130
|
+
|
131
|
+
public class SecurityController {
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
private final SiteUserRepository userRepository;
|
136
|
+
|
137
|
+
private final BCryptPasswordEncoder passwordEncoder;
|
138
|
+
|
139
|
+
private final AttendanceRepository attendanceRepository;
|
140
|
+
|
141
|
+
(...)
|
142
|
+
|
143
|
+
@GetMapping("/attendance")
|
144
|
+
|
145
|
+
public ModelAndView createAttendance (ModelAndView mv, @ModelAttribute("attendance") Authentication SiteUser) {
|
146
|
+
|
147
|
+
mv.setViewName("test1");
|
148
|
+
|
149
|
+
mv.addObject("attendance", new Attendance());
|
150
|
+
|
151
|
+
return mv;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
### 試したこと
|
164
|
+
|
165
|
+
コントローラのmv.addObject("attendance", new Attendance());
|
166
|
+
|
167
|
+
htmlの th:object="${Attendance}"とth:value= を削除したところ、entitiyと関係のないhtmlの出力はできたので、entitiyに問題があると考えています。
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
### 補足情報(FW/ツールのバージョンなど)
|
172
|
+
|
173
|
+
Spring Tools 4 for Eclipse
|
174
|
+
|
175
|
+
Spring Boot 2. 3. 5
|