十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇文章为大家展示了如何android在中使用springMvc实现图片上传功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

具体内容如下
Android端:
String fileName = tvFilename.getText().toString();
RequestBody description =
RequestBody.create(
okhttp3.MultipartBody.FORM, fileName);
File fileImage = new File(saveFileName);
RequestBody requestBody1 =
RequestBody.create(MediaType.parse("multipart/form-data"), fileImage);
MultipartBody.Part body =
MultipartBody.Part.createFormData("bannerImage", fileImage.getName(), requestBody1);
RestClient.api().addLive(description, body)
.enqueue(new retrofit2.Callback() {
@Override
public void onResponse(retrofit2.Call call, retrofit2.Response response) {
"处理成功"
}
@Override
public void onFailure(retrofit2.Call call, Throwable t) {
"处理失败"
}
});