0

我正在尝试通过放大请求上传文件和一些数据提交。我正在使用弹簧框架工作。我想上传文件以及一些 json 数据。我的代码示例如下。我收到请求参数文件不可用作为例外。

amplify.request.define( "UpdateCompanyProfile", 
            "ajax", 
            { 
                url: "updatecomanyprofile.htm", 
                dataType: "json",
                type: "POST"

            }
    );          

    amplify.request({
        resourceId: "UpdateCompanyProfile",
        success: function(data, status) {               
        },
        error: function(data, status) {             
        }
    });
           bus.data.publish({
            topic: "UpdateCompanyProfile.fetch",
            resourceId: "UpdateCompanyProfile",
            successReplyTo: "UpdateCompanyProfile.fetched",
            data: $('#companyProfileForm').serialize() + '&' + $.param(JSON.stringify(companyProfileObj)) 
        });

bus.data.subscribe( "UpdateCompanyProfile.fetched", function(data){
            // my stuff;
        });

和我的控制器

 @RequestMapping(value = UrlPrefix.employer+"/updatecomanyprofile.htm", method = RequestMethod.POST)
public void updateCpmpanyProfile(@ModelAttribute OrganizationDetail organizationDetail, BindingResult bind, ModelMap model, SessionStatus status,@RequestParam("file")MultipartFile f,HttpServletRequest request,HttpServletResponse response) {
    UserBasicInfo user = (UserBasicInfo) request.getSession(false).getAttribute("user");
    ObjectMapper mapper  = null;
    MainJson mainJson = new MainJson();
     mapper = new ObjectMapper();
     try {
         BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
            String json = "";
            if(br != null){
                json = br.readLine();
                mapper = new ObjectMapper();
               logger.logDebug(" Update JSON :"+json);
               organizationDetail = mapper.readValue(json, OrganizationDetail.class);
            }
    } catch (Exception e) {
        e.printStackTrace();
        mainJson.setData(null);
        mainJson.setStatus("error");
    }

}

任何人请帮助我。提前致谢。

4

0 回答 0