1

我正在尝试上传文件,但使用@FormDataParam不允许应用程序部署。感兴趣的代码如下:

@POST
@Path("sync")
public String callServletSyncPost (
        @PathParam("tapschema") String tapschema,
        @FormParam("REQUEST") String request,
        @FormParam("LANG") String lang,
        @FormParam("QUERY") String query,
        @FormParam("UPLOAD") String upload,
        //@FormDataParam("file") File fileUpload
        @FormDataParam("file") InputStream fileUpload,
        @FormDataParam("file") FormDataContentDisposition fileDetail
        )
        throws Exception {

我在项目中添加了以下库:

  • asm-3.1.jar

  • 杰克逊核心asl-1.1.1.jar

  • jersey-client-1.2.jar

  • jersey-core-1.2.jar

  • jersey-json-1.2.jar

  • jersey-server-1.2.jar

  • 抛弃-1.1.jar

  • jsr311-api-1.1.1.jar

  • mimepull.jar

  • jersey-multipart.jar

我也尝试添加jersey-bundle-1.2.jar库,但应用程序未部署。

在 Glassfish 3.1 日志页面中有以下日志:

The following errors and warnings have been detected with resource and/or provider classes: SEVERE: Missing dependency for method public java.lang.String it.inaf.oats.ia2.tap.implementation.TapRestImpl.callServletSyncPost(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.io.File) throws java.lang.Exception at parameter at index 5 SEVERE: Missing dependency for method public java.lang.String it.inaf.oats.ia2.tap.implementation.TapRestImpl.callServletSyncPost(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.io.File) throws java.lang.Exception at parameter at index 5 SEVERE: Method, public java.lang.String it.inaf.oats.ia2.tap.implementation.TapRestImpl.callServletSyncPost(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.io.File) throws java.lang.Exception, annotated with POST of resource, class it.inaf.oats.ia2.tap.implementation.TapRestImpl, is not recognized as valid resource method.

有人能告诉我为什么应用程序没有部署以及如何解决这个问题吗?提前致谢

4

1 回答 1

0

如果你的函数返回 smth(fe json) 你应该添加

@Produces(MediaType.APPLICATION_JSON)

和参数

@Consumes(MediaType.MULTIPART_FORM_DATA)
于 2013-10-14T10:48:51.870 回答