質問編集履歴
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,29 +31,10 @@
|
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
-
同じような形で
|
35
34
|
|
36
|
-
ListのProfileで登録ユーザー一覧に画像を表示したい場合
|
37
35
|
|
38
|
-
```java
|
39
|
-
@GetMapping(path = "usersList")
|
40
|
-
String usersList(@RequestParam Integer genderId, Model model){
|
41
|
-
List<Profile> profile = profileService.findUsers(genderId);
|
42
36
|
|
43
|
-
//画像ファイルをBASE64形式でエンコード
|
44
37
|
|
45
|
-
model.addAttribute("profile", profile);
|
46
|
-
|
47
|
-
.
|
48
|
-
.
|
49
|
-
.
|
50
|
-
.
|
51
|
-
return "konkatsu/profileList";
|
52
|
-
}
|
53
|
-
```
|
54
|
-
|
55
|
-
|
56
|
-
|
57
38
|
どのように書き換えたら良いのでしょうか???
|
58
39
|
この理論であっていますか??
|
59
40
|
|
@@ -76,4 +57,26 @@
|
|
76
57
|
<td th:text="${profile.user.mail}">duke</td> <!-- 「profile」オブジェクトがもつ「user」の「mail」を表示 -->
|
77
58
|
<td th:text="${profile.text}">仮</td>
|
78
59
|
</tr>
|
79
|
-
```
|
60
|
+
```
|
61
|
+
|
62
|
+
同じような形で
|
63
|
+
|
64
|
+
ListのProfileで登録ユーザー一覧に画像を表示したい場合
|
65
|
+
|
66
|
+
```java
|
67
|
+
@GetMapping(path = "usersList")
|
68
|
+
String usersList(@RequestParam Integer genderId, Model model){
|
69
|
+
List<Profile> profile = profileService.findUsers(genderId);
|
70
|
+
|
71
|
+
|
72
|
+
String encodedImage = Base64.getEncoder().encodeToString(profile.getImage());
|
73
|
+
System.out.println(encodedImage);
|
74
|
+
|
75
|
+
model.addAttribute("image", encodedImage);
|
76
|
+
model.addAttribute("profile", profile);
|
77
|
+
return "konkatsu/profileList";
|
78
|
+
}
|
79
|
+
```
|
80
|
+
|
81
|
+
profile.getImage()でエラーとなってしまいます
|
82
|
+
List Profileに格納されているimageを出力したいです
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -36,23 +36,20 @@
|
|
36
36
|
ListのProfileで登録ユーザー一覧に画像を表示したい場合
|
37
37
|
|
38
38
|
```java
|
39
|
-
@GetMapping(path = "
|
39
|
+
@GetMapping(path = "usersList")
|
40
|
-
|
40
|
+
String usersList(@RequestParam Integer genderId, Model model){
|
41
|
-
|
41
|
+
List<Profile> profile = profileService.findUsers(genderId);
|
42
42
|
|
43
|
-
|
43
|
+
//画像ファイルをBASE64形式でエンコード
|
44
44
|
|
45
|
-
|
45
|
+
model.addAttribute("profile", profile);
|
46
|
-
|
46
|
+
|
47
|
-
|
48
|
-
|
49
|
-
|
50
47
|
.
|
51
48
|
.
|
52
49
|
.
|
53
50
|
.
|
54
|
-
|
51
|
+
return "konkatsu/profileList";
|
55
|
-
|
52
|
+
}
|
56
53
|
```
|
57
54
|
|
58
55
|
|
2
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -62,4 +62,21 @@
|
|
62
62
|
|
63
63
|
```java
|
64
64
|
String encodedImage = Base64.getEncoder().encodeToString(ここにリストProfileのimageを入れたいのです));
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
```html
|
69
|
+
|
70
|
+
<tr th:each="profile : ${profile}">
|
71
|
+
<!-- エンコードした画像の表示 -->
|
72
|
+
<td><img th:src="${'data:image/png;base64,' + image}" width="250" height="150"/></td>
|
73
|
+
<td th:text="${profile.name}">山田</td>
|
74
|
+
<td th:text="${profile.gender.gender}">山田</td>
|
75
|
+
<td th:text="${profile.birthday}">仮</td>
|
76
|
+
<td th:text="${profile.height}">仮</td>
|
77
|
+
<td th:text="${profile.occupation.occupationName}">仮</td>
|
78
|
+
<td th:text="${profile.income}">仮</td>
|
79
|
+
<td th:text="${profile.user.mail}">duke</td> <!-- 「profile」オブジェクトがもつ「user」の「mail」を表示 -->
|
80
|
+
<td th:text="${profile.text}">仮</td>
|
81
|
+
</tr>
|
65
82
|
```
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,30 +31,32 @@
|
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
+
同じような形で
|
35
|
+
|
36
|
+
ListのProfileで登録ユーザー一覧に画像を表示したい場合
|
37
|
+
|
34
38
|
```java
|
35
|
-
@GetMapping(path = "
|
39
|
+
@GetMapping(path = "myProfile")
|
36
|
-
|
40
|
+
String MyList(@RequestParam Integer id, Model model){
|
37
|
-
|
41
|
+
Profile profile = profileService.findProfile(id);
|
38
42
|
|
39
|
-
//画像ファイルをBASE64形式でエンコード
|
40
|
-
// String encodedImage = Base64.getEncoder().encodeToString(profile.image());
|
41
|
-
|
43
|
+
String encodedImage =
|
42
44
|
|
45
|
+
Base64.getEncoder().encodeToString(???);
|
46
|
+
//ここで画像ファイルをBASE64形式でエンコードしたいです
|
43
47
|
|
44
|
-
|
48
|
+
|
45
|
-
System.out.println(profile.get(0));
|
46
|
-
/* String encodedImage = Base64.getEncoder().encodeToString(profile);
|
47
|
-
System.out.println(encodedImage);
|
48
49
|
|
49
|
-
|
50
|
+
.
|
50
|
-
|
51
|
+
.
|
52
|
+
.
|
53
|
+
.
|
51
|
-
|
54
|
+
return "konkatsu/myProfile";
|
52
|
-
|
55
|
+
}
|
53
|
-
|
54
56
|
```
|
55
57
|
|
56
|
-
Listで登録ユーザー一覧に画像を表示したい場合
|
57
58
|
|
59
|
+
|
58
60
|
どのように書き換えたら良いのでしょうか???
|
59
61
|
この理論であっていますか??
|
60
62
|
|