上传到CXF restful Web服务

时间:2010-07-28 16:03:08

标签: java web-services file-upload cxf apache-commons

我正在尝试在我的cxf restful web服务中实现apache commons fileupload。出于某种原因,ServletFileUpload.isMultipartContent(...) 始终返回false;我通过httpServletRequest.getContentType()检查了内容类型,并按预期返回multipart / form-data。有谁知道是什么导致isMultipartContent方法返回false?以下是我的代码:

    @POST
    @Path("/images")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response uploadImages(@Context javax.servlet.http.HttpServletRequest httpRequest) {
        List items = null;
        boolean isMultipart = ServletFileUpload.isMultipartContent(httpRequest);
        if (isMultipart) {
        ...
        ...
        } else { return Response.status(Status.BAD_REQUEST).build(); }

0 个答案:

没有答案