本篇文章為大家展示了如何android在中使用springMvc實現(xiàn)圖片上傳功能,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
具體內(nèi)容如下
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) { "處理失敗" } });