用于文件上传的Liferay休息端点

时间:2017-09-01 08:15:59

标签: java spring rest liferay

我正在尝试在Liferay中创建用于文件上传的REST端点,但不能使用ActionRequest。当我尝试使用它时,我一直得到:

Handler execution resulted in exception: Required MultipartFile parameter 'file' is not present resourceId:personUpload

我的控制器:

@ResourceMapping(value = "personUpload")
public List<ChInsuredPerson> uploadExcel(@RequestParam("file") MultipartFile file, HttpServletResponse response) throws Exception {

    List<ChInsuredPerson> insuredPeople = new ArrayList<ChInsuredPerson>();
    try {
        insuredPeople = personUploadService.extractInsuredPersons(file.getInputStream());
    } catch (IllegalStateException e) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }

    return insuredPeople;

}

我用Postman调用端点是这样的: enter image description here

0 个答案:

没有答案