html
1<!DOCTYPE html> 2<html xmlns:th="http://www.thymeleaf.org"> 3<head> 4 <meta charset="utf-8"/> 5 <title>プロフィール一覧</title> 6 </head> 7<body> 8<table> 9 <tr th:each="profile : ${profile}"> 10 <td th:text="${profile.name}"> 山田花子</td> 11 <td th:text="${profile.birthday}"> 1999-01-09</td> 12 <td th:text="${profile.height}"> 178</td> 13 <td th:text="${profile.occupationId}"> 仮</td> 14 <td th:text="${profile.income}"> 仮</td> 15 <td th:text="${profile.text}"> 仮</td> 16 <td th:src="${profile.image}"> 仮</td> 17 <td> 18 19 <form th:action="@{/profile/edit}" method="get"> 20 <input type="submit" name="form" value="編集" /> 21 <input type="hidden" name="userId" th:value="${profile.userId}" /> 22 </form> 23 24 </td> 25 </tr> 26</table> 27</body> 28</html>
java
1package com.example.konkatsu.domain; 2 3import java.sql.Date; 4 5import javax.persistence.Entity; 6import javax.persistence.GeneratedValue; 7import javax.persistence.Id; 8import javax.persistence.Table; 9import javax.validation.constraints.NotNull; 10 11import lombok.AllArgsConstructor; 12import lombok.Data; 13import lombok.NoArgsConstructor; 14 15@Data 16@NoArgsConstructor //デフォルトコンストラクタも必要な場合 17@AllArgsConstructor //すべてのフィールドを引数に持つコンストラクタを自動生成 18@Entity //エンティティ(一単位として扱われるデータのまとまり)であることを示す。指定したクラス名がテーブルとマッピングされる 19@Table(name = "profile") //接続するテーブルを指定 20public class Profile { 21 @Id //主キー 22 @GeneratedValue //自動採番される 23 private Integer userId; 24 @NotNull 25 private Integer genderId; 26 @NotNull 27 private String name; 28 @NotNull 29 private Date birthday; 30 @NotNull 31 private Integer height; 32 @NotNull 33 private Integer occupationId; 34 @NotNull 35 private Integer income; 36 @NotNull 37 private String text; 38 @NotNull 39 private byte[] image; 40 41} 42
この場合htmlから
<td th:src="${profile.image}"> 仮</td> ここでデータベースから画像データを取り込みたいのですが 表示されません
他のnameなどは表示されます
データベースにちゃんと画像データは入っています
どなたか教えていただけないでしょうか??
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/03 04:11
2017/07/03 04:19