Can#39;t find @FormDataParam in Jersey 2.17(在 Jersey 2.17 中找不到 @FormDataParam)
问题描述
我对 Web 服务还很陌生,所以我从基本示例开始.这与文件上传有关.我正在为非 Maven 开发人员使用最新 (2.17) 版本的 Jersey 捆绑包.它指出:
I'm quite new to web services so I've started with basic examples. This one relates to file upload. I'm using latest (2.17) version of Jersey bundle for non-maven developers. It states that:
bundle 包含 JAX-RS 2.0 API jar、所有核心 Jersey 模块 jar 以及所有必需的第 3 方依赖项
bundle contains the JAX-RS 2.0 API jar, all the core Jersey module jars as well as all the required 3rd-party dependencies
.问题是我无法编译这部分:
. The problem is that I can not compile this part:
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
String uploadedFileLocation = "d://uploaded/" + fileDetail.getFileName();
// save it
writeToFile(uploadedInputStream, uploadedFileLocation);
String output = "File uploaded to : " + uploadedFileLocation;
return Response.status(200).entity(output).build();
}
似乎 @FormDataParam
在 Jersey 2.17 捆绑包中不存在,尽管文档说它存在.2.17 捆绑包不完整吗?我该如何解决这个问题?
It seems that @FormDataParam
doesn't exist in Jersey 2.17 bundle although docs says it does. Is the 2.17 bundle incomplete? How can I resolve this problem?
推荐答案
捆绑包仅包含核心模块(及其依赖项).不幸的是,Multipart 不是核心的一部分.您还需要 此依赖项 (Maven)
The bundle only includes the the core modules (and their dependencies). Unfortunately, Multipart is not part of the core. You'll need this dependency (Maven) also
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.17</version>
</dependency
如果您不使用 Maven,据我所知,这个工件只有一个其他依赖项(尚未包含在包中),它是 mimepull-1.9.3
.
If you're not using Maven, from what I can tell, this artifact only has one other dependency (that is not already included in the bundle), and it's mimepull-1.9.3
.
您可以在下面下载这两个工件
You can download both artifacts below
- jersey-media-multipart
- mimepull-1.9.3
这篇关于在 Jersey 2.17 中找不到 @FormDataParam的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Jersey 2.17 中找不到 @FormDataParam


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01