How can I define a JAX-RS service that processes multi-part data in JEE?(如何在 JEE 中定义处理多部分数据的 JAX-RS 服务?)
问题描述
这是我目前所拥有的:
这会初始化我的 REST 服务
这就是我的服务的样子:
我尝试将 @MultipartConfig
添加到 JaxRsActivator
,但仍然收到异常:Request.getParts is called without multipart configuration.将 @MultipartConfig 添加到 servlet,或将 multipart-config 元素添加到 web.xml.
I tried adding @MultipartConfig
to JaxRsActivator
, but I still get an Exception: Request.getParts is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml.
谢谢
推荐答案
最后我设法在没有 Jersey 耦合的情况下完成了这个工作.问题是 @Multipart
注释不适用于 Application
,因此您需要在 web.xml 和 Application
中定义它类定义提供的服务.在服务内部,您可以正常使用注释.另请注意,我正在从请求中提取 Parts
,但这很容易.
Finally I managed to get this working by without Jersey coupling.
The problem is that @Multipart
annotation doesn't work with the Application
, so you need to define it inside web.xml and inside the Application
class define the provided service. Inside the services you can use annotations normally. Also note, that I am extracting the Parts
from the request, but this is very easy.
PS.这实际上实现了 bluimp JQuery 文件上传
PS. This actually implements the back-end for bluimp JQuery file upload
web.xml
JaxRsActivator.java
文件上传.java
这篇关于如何在 JEE 中定义处理多部分数据的 JAX-RS 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!