从multipartFormData中的hashMap中检索数据

时间:2015-04-10 00:41:29

标签: java hashmap multipartform-data

我的方法遇到了一些麻烦,我可以打印地图,如果其中只有1个项目,但是如果我放了超过1个,我会遇到一个超出范围的异常,我有没有某些事情执行不正确?

public static Result update(){

        //get the body of the request
        RequestBody body = request().body();
        //Assign the type as MultipartFormData
        Http.MultipartFormData multippartBody = body.asMultipartFormData();
        // Pull the video from the MultipartFormData
        Http.MultipartFormData.FilePart videoFile = multippartBody.getFile("fileKey");
        // Pull the hashMap from the MultipartFormData
        Map<String, String[]> myMap  = multippartBody.asFormUrlEncoded();

        System.out.println(myMap.size());
        // Loop to print the contents of the hashMap
        for(int i =0; i < myMap.size(); i++){
            String param = "param" + (i + 1);
            System.out.println(myMap.get(param)[i]);    
        }

        }

0 个答案:

没有答案