【发布时间】:2019-04-17 20:30:25
【问题描述】:
我使用 MYSQL Blob 将图像存储在数据库中。现在我想在我上传的 IONIC 应用程序中显示图像。
它是如何工作的以及如何将它存储在一个对象中?
你可以在这里找到我的代码:
Java 类
public JSONObject getItems(String email) throws SQLException, ClassNotFoundException, IOException {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
Connection conn = new MYSQLAccess().getConnection();
String sql = "SQL String";
PreparedStatement pstm = conn.prepareStatement(sql);
pstm.setString(1, email);
ResultSet rs = pstm.executeQuery();
while (rs.next()) {
jsonObject.put("1", rs.getBlob("1"));
jsonObject.put("2",rs.getInt("2"));
jsonObject.put("3", rs.getString("3"));
jsonObject.put("4", rs.getString("4"));
jsonArray.add(performanceCarsJsonObject);
}
jsonObject = new JSONObject();
jsonObject.put("array", jsonArray);
conn.close();
return jsonObject;
}
TypeScript Ionic/Angular
getPerformanceCars() {
let params = {"email": this.user.getEmail()};
this.cars.performanceCars(params).then(data => {
this._List = data;
this._List = this._List.value.icons;
this.itemList = this._List;
});
}
离子 HTML
<ion-list>
<ion-item-sliding *ngFor="let items of itemList">
<button ion-item (click)="openItem(item)">
<ion-avatar item-start>
<img [src]="items.img" />
</ion-avatar>
<h2>{{ items.email }}</h2>
<p>{{ items.values }}</p>
<ion-note item-end *ngIf="items.note">{{ cars.note }}</ion-note>
</button>
</ion-item-sliding>
</ion-list>
IONIC Input Uploader 中的照片预览使用以下 HTML 代码。
<div class="profile-image" style="background-image: url("data:image/jpeg;base64,DATA;);"></div>
我希望你能帮助我,解决我的问题。
【问题讨论】:
标签: java mysql angular spring-mvc ionic-framework