小编ila*_*nto的帖子

jersey multiparty返回NoClassDefFoundError:org/glassfish/jersey/internal/inject/ExtractorException

我正在尝试创建一个使用/上传图像文件的API

我已经像这样配置了我的应用:

ResourceConfig文件

@ApplicationPath("api")
 public class appConfig extends ResourceConfig {
public appConfig() {
    // Register resources and providers using package-scanning.
    packages("src.main.java.org.vaad.vaadAPI");
    register(MultiPartFeature.class);
    register(LoggingFilter.class);

    // temp disabled for testing 

}
Run Code Online (Sandbox Code Playgroud)

资源文件:

@POST
@Path("/user/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
        @FormDataParam("file") InputStream fileInputStream,
         @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
    String SERVER_UPLOAD_LOCATION_FOLDER = "C://Upload_Files/";
    String filePath = SERVER_UPLOAD_LOCATION_FOLDER + contentDispositionHeader.getFileName();

    // save the file to the server
//  saveFile(fileInputStream, filePath);

    String output = "File saved to server location : " + filePath;

    return Response.status(200).build();

}
Run Code Online (Sandbox Code Playgroud)

的pom.xml

<dependency> …
Run Code Online (Sandbox Code Playgroud)

java rest multipartform-data jersey-2.0

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

jersey-2.0 ×1

multipartform-data ×1

rest ×1