Uploading file using Jersey over RESTfull service and The resource configuration is not modifiable?

前端 未结 6 982
误落风尘
误落风尘 2020-12-13 04:15
@Path(\"file.upload\")
public class UploadFileService {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
        @FormDataParam(\"file\") I         


        
6条回答
  •  無奈伤痛
    2020-12-13 04:56

    In order to use multipart in your Jersey application you need to register MultiPartFeature in your application, i.e.:

    public class ApplicationConfig extends Application {
    
        public Set> getClasses() {
            final Set> resources = new HashSet>();
    
            // Add your resources.
            resources.add(UploadFileService.class);
    
            // Add additional features such as support for Multipart.
            resources.add(MultiPartFeature.class);
    
            return resources;
        }
    }
    

    For more information see Multipart section in the Jersey Users Guide.

    For the second issue you're facing try to restart the GlassFish server, I am not sure how NetBeans are reloading the Jersey app after a change (if this doesn't help, please post your ApplicationConfig).

提交回复
热议问题